1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-22 04:34:19 +00:00

🔧 Allow BulletMovement to detect collisions

This commit is contained in:
Steffo 2022-04-03 08:48:01 +02:00
parent edc036941f
commit 625631a0f0
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -4,7 +4,11 @@ onready var target: KinematicBody2D = get_parent()
export var movement_per_second: float = 400.0
signal hit(collision)
func _physics_process(_delta):
var direction = Vector2(cos(target.rotation), sin(target.rotation))
# TODO: Maybe bullets shouldn't slide but collide
var _motion: Vector2 = target.move_and_slide(direction * movement_per_second)
var collision: KinematicCollision2D = target.move_and_collide(direction * movement_per_second)
if collision != null:
emit_signal("hit", collision)