#can anyone tell me how this variable works

2 messages · Page 1 of 1 (latest)

shut ginkgo
#

var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

hazy venture
#

It's used to get the direction that the player will move. You would usually set the player's x and z velocity to the x and z of direction. input_dir is a Vector2 that represents the player's movement input. Usually, you make the input_dir variable like this:

var inputDir = Input.get_vector("Left", "Right", "Forward", "Back")

You can replace the strings in the get_vector() method with watever you named your left, right, forward, and back buttons in the Input Map.