Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | chahro |
i have make a 3d shooting spaceship game and i didn’t know how to make enemy explode when it get shot
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | chahro |
i have make a 3d shooting spaceship game and i didn’t know how to make enemy explode when it get shot
Reply From: | stormreaver |
You create a separate explosion scene. When your spaceship needs to explode, you create a new instance of your explosion scene, place it at the location of the exploding ship, then delete your ship.
Reply From: | theMX89 |
if your bullet that hits your ship, has an area, do this in the bullets script: connect the area to your main script on “area body entered”, then you will get this:
func _on_Area_body_entered(body):
pass
you add:
func _on_Area_body_entered(body):
var spaceship = get_node("root to your spaceship")
if body.get_name() == "spaceship":
$animationplayer.play("explosion")
spaceship.visible = false
to do this, add an animationplayer an make the explosion with the animationplayer.