forked from Goldenlion5648/GodotIsometricCollisionExample
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCharacterBody2D.gd
More file actions
22 lines (18 loc) · 737 Bytes
/
CharacterBody2D.gd
File metadata and controls
22 lines (18 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extends CharacterBody2D
const SPEED = 64
var left_mouse_pressed = false
var left_mouse_direction = Vector2.ZERO
@warning_ignore("unused_parameter")
func _physics_process(delta: float) -> void:
var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") + left_mouse_direction
velocity = direction * SPEED
move_and_slide()
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
left_mouse_pressed = event.pressed
left_mouse_direction = Vector2.ZERO # Initialization
elif event is InputEventMouseMotion:
if left_mouse_pressed and !event.relative.is_normalized():
left_mouse_direction = event.relative.limit_length()
#else: print(event)