- Edited
so im trying to normalise the players movement but it keeps throwing the error
Invalid call. Nonexistent function 'normalised' in base 'Vector2'
the code is pretty simple so i cant figure out what im doing wrong
extends KinematicBody2D
export var speed: float
func _physics_process(delta):
var direction = Vector2(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
)
if direction.length() > 1.0:
direction = direction.normalised()
print(direction)
move_and_slide(speed * direction)
the error only appears when trying to move diagonally, however it works with a controller joystick if you dont go at a perfect diagonal
im quite new to godot and gdscript (moving from unity and c#) so i could easily be making an obvious error and not realise