Projectile dysfunction

I have the player and the projectile, I know how to do this in 3D but not in 2D, tried to monkey around but nothing really came out of it except bad code.

	if Input.is_action_pressed("gun") && canfire:
		$Laser.play()
		$Cooldown.start(0.3)
		var instance = projectile.instantiate()
		instance.global_position = global_position
		instance.transform = global_transform
		canfire = false

The projectiles are removed after 5 seconds of existence, which is enough for most people. I appreciate the help!

you need to add the projectile instance as a child to something

so in your case it would be level.add_child(instance)
then you can mess with its position and whatnot

Thank you very much, it worked quite well!

1 Like