Help with bullet

Godot Version

Godot_V.4.2.2

Question

I have a bullet and i want to bullet move so i set a script.And when i run bullet is going superslow no mather what speed i put.This is the code:

var speed = 200
func _physics_process(delta):
velocity = Vector2(1, 0)
var shoot = (velocity * delta * speed)
move_and_slide()

you just set a variable to your velocity times delta times your speed variable. Your velocity remains sill the same since you only set it once in your script (velocity = Vector2(1, 0)).
To change the velocity of your bullet you will have to set the velocity accordingly:

func _physics_process(delta):
   # no delta needed since your are not changing your velocity over time (constant velocity)
   velocity = Vector2(speed, 0)
   move_and_slide()

In addition there is no real point in constantly setting your velocity to the same value. This would work fine as well:

func _ready():
   velocity = Vector2(speed, 0)

func _physics_process+delta):
   move_and_slide()

that seems to work good,thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.