Script a object shooting arrow to player. At first use player's translation
minus arrow's translation
after set the same y, then normalize the results to get dir
, using move_and_slide(dir * speed)
to move the arrow, sometimes the arrow moving direction is right sometimes wrong. After doing some search it seems the translation
is local, then change it to get_global_transform().origin
, but the results is kind same as before. How to calculate that correctly?
Thanks!
edit: used look at to rotate
the arrow, somehow it change the position of the arrow, so change it to rotate
, problem solved