Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- export var speed = 200
- var velocity = Vector2()
- var mouse_position = null
- func _physics_process(delta):
- # Reset the player's velocity
- velocity = Vector2(0, 0)
- mouse_position = get_global_mouse_position()
- # This input will need to be created in the input map
- if Input.is_action_pressed("forward"):
- var direction = (mouse_position - position).normalized()
- velocity = (direction * speed)
- move_and_slide(velocity)
- look_at(mouse_position)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement