18 lines
353 B
GDScript
18 lines
353 B
GDScript
extends CharacterBody2D
|
|||
|
|
|
||
|
|
@export var speed: float = 5
|
||
|
|
const _speed_mult: float = 200
|
||
|
|
var _direction: Vector2 = Vector2(1.0, 0.5)
|
||
|
|
|
||
|
|
func _physics_process(delta):
|
||
|
|
velocity.x = speed * _speed_mult * _direction.x
|
||
|
|
velocity.y = speed * _speed_mult * _direction.y
|
||
|
|
|
||
|
|
move_and_slide()
|
||
|
|
|
||
|
|
func invert_x():
|
||
|
|
_direction.x *= -1
|
||
|
|
|
||
|
|
func invert_y():
|
||
|
|
_direction.y *= -1
|