Hello, I'm a new guy in programming. I don't know why bullet have a wrong velocity when it spawn. I have a few functions _on_ShootCooldown_timeout()
and func _on_ExitingTimer_timeout():
First function must spawn bullet. And Second must delete it.
This is code for thats functions:
func _on_ShootCooldown_timeout():
bullet.initiateTarget(player)
bullet.position = $Weapon.global_position
scene.add_child(bullet)
bullet.look_at(player.global_position)
$ExitingTimer.start()
func _on_ExitingTimer_timeout():
scene.remove_child(bullet)
And for bullet we have this code
func _physics_process(delta):
position += velocity * bullet_speed * delta
func makeVelocity():
velocity = position.direction_to(target.global_position).normalized()
func initiateTarget(targ):
target = targ
Please, anyone help me. I don't understand when I do mistake.