Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Wielblad |
Hi!
I’m having a problem with making explosion. I have scene called explosion that is Area2D and it is spawned by player, who shoots rocket. I also have falling object that is RigidBody2D. And I want to make it so explosion pushes object away, and the point will be to keep object in air. And right now object just falls through explosion, no interaction made. And I don’t know what am I doing wrong. Explosion and object are on same collision masks and layers. Code:
extends Area2D
onready var exploTime = get_node("ExplosionTime")
func _ready():
hide() #spawns at click and hides, so I could use look_at
func _on_Explosion_area_entered(area):
show() #shows when rocket enters
exploTime.start() # duration of explosion start
func _on_ExplosionTime_timeout():
queue_free() # deletes explosion
func _on_Explosion_body_entered(body):
body.apply_impulse(Vector2(0,0), Vector2(100,100)) #arbitrary vector to just check if working
pass # replace with function body
Object have none code yet. How should I make it working? Also I would ask you to explain this to me as I am still learning and want to understand this thing.
Thanks a lot guys!