Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- export (int) var speed = 500
- var target = Vector2()
- var velocity = Vector2()
- func _physics_process(delta):
- target = get_global_mouse_position()
- velocity = position.direction_to(target) * speed
- look_at(target)
- if position.distance_to(target) > 5:
- velocity = move_and_slide(velocity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement