Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends CharacterBody2D
- var speed = 300
- var mouse_position = Vector2()
- var target_position = Vector2()
- func _physics_process(delta):
- mouse_position = get_global_mouse_position()
- target_position = (mouse_position - position).normalized()
- # This input will need to be created in the input map
- if Input.is_action_pressed("up"):
- velocity = target_position * speed
- move_and_slide()
- # This input will need to be created in the input map
- if Input.is_action_pressed("down"):
- velocity = -target_position * speed
- move_and_slide()
- look_at(mouse_position)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement