This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I am working on a stg game, and I find the moving speed of the projectile is weird. The projectile moves faster when the player move in the y direction. But I want the speed keep constantly, how could I fix this?


Player movement code:

var velocity = Vector2(0,0)
var speed = 300
func _process(delta):
velocity.x = int(Input.is_action_pressed("move_right")) - int(Input.is_action_pressed("move_left"))
velocity.y = int(Input.is_action_pressed("move_down")) - int(Input.is_action_pressed("move_up"))

velocity = velocity.normalized()

global_position += velocity * speed * delta

Projectile movement code:

var velocity = Vector2(0, -1)
export var speed = 500

func _process(delta):
global_position += velocity * speed * delta

shooting speed problem

Godot version 3.3 stable
in Engine by (12 points)

1 Answer

0 votes

I usually add the speed of the unit firing the bullet to the bullet speed right before I add it to the scene. Especially if the unit is fast.

Also, I usually use Vector2.RIGHT rather than Vector2.UP like you did.. Maybe, try Vector2.RIGHT, to see if using the x-axis changes it....

What node are you using for the projectile? Area2D?

oh, and maybe try using physics process instead of process.

by (214 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.