Godot Version
<stable4.2>
Question
<Hello. I would appreciate if you could teach me a reason why enemy’s projectile is not being fired at player’s position precisely.
func _shoot():
var mage_ball = mageballScene.instantiate()
mage_ball.global_position = $MageBallSpawner.global_position
mage_ball.direction = global_position.direction_to(player.global_position)
get_parent().add_child(mage_ball)```
extends CharacterBody2D
var speed := 125
var max_range := 300.0
var _travelled_distance = 0.0
#var direction = Vector2.ZERO
func _init():
set_as_top_level(true)
func _physics_process(delta: float) -> void:
var distance := speed * delta
var motion : Vector2 = direction * speed * delta
position += motion