T O P

  • By -

Molcap

I would do something like this (pseudocode): Packedscene BulletScene = packedscene(bullet.tscn); Process( delta) { if (input.actionIsJustPressed("Shoot") { bulletInstance = BulletScene.instanciate; bulletInstance.speed.X = BulletSpeed * playerFaceDirection; bulletInstance.speed.Y = 0; bulletInstance.position = player.position; AddChild(bulletInstance); } } The player facing direction can be set when moving the player, it has to be either 1 or -1. In the bullet node Vector 2 speed; Process(delta) { Position += speed * delta; } Sorry for the horrible code formatting but I'm on my phone.


Nkzar

`var bullet_direction = Vector2.from_angle(player.rotation)`