Advertisement
opaBR

[FUNC] Mover para direção do mouse

Feb 3rd, 2021 (edited)
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. extends KinematicBody2D
  3.  
  4. export (float) var speed : float = 250.0
  5.  
  6. func _physics_process(delta: float) -> void:
  7.     var vel := (speed * dir() * delta)
  8.     vel = move_and_slide(vel)
  9.    
  10.  
  11. func dir() -> Vector2:
  12.     var _dir : Vector2
  13.     _dir = (get_global_mouse_position() - global_position).floor()
  14. #   _dir = (get_global_mouse_position() - global_position).floor().clamped(100)
  15.     print(_dir.length())
  16.     return _dir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement