![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | nanto2016 |
In the CharacterBody3D script template, inside _physics_process()
there is this code:
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
I do not understand what the if direction
means… direction
is a Vector3
so how can i beused as a boolean inside if
?