【发布时间】:2019-08-02 11:36:27
【问题描述】:
我正在尝试让精灵在 x 和 y 与鼠标相同时停止移动。
由于某种原因,一旦图像与鼠标处于同一位置,图像就会开始在同一轴上来回快速移动。我需要让它停止移动。
func _physics_process(delta):
var move_vec = Vector2()
var look_vec = get_global_mouse_position() - global_position
//this gets the mouse and sprite position
if move_vec != look_vec: // if mouse and sprite are not the same then move.
move_vec = look_vec
move_vec = move_vec.normalized()
move_and_collide(move_vec * speed * delta)
global_rotation = atan2(look_vec.y, look_vec.x)
else:
pass`enter code here`
【问题讨论】:
标签: game-physics godot gdscript