![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | pekweieie |
Hey, relatively new to Godot here. I tried coding a bullet (RigidBody2D Node) that would hide itself after hitting a wall. I used the body_entered() signal for when the bullet hits a wall and doesn’t seem to work. idk what I supposed to do here. Also I coded a timer so that the bullet would delete itself after 1 second.
extends RigidBody2D
var projectile_speed = 1000.0
var lifetime = 1
func _ready() -> void:
apply_impulse(Vector2(), Vector2(projectile_speed, 0).rotated(rotation))
self.contact_monitor = true
selfdestruct()
func _on_Bullet_body_entered(body):
self.hide()
func selfdestruct():
yield(get_tree().create_timer(lifetime),"timeout")
queue_free()
Have you checked if the signal is connected?
sinistro25 | 2020-09-12 01:09