#how do i make my player move in the direction of my camera in an fps

1 messages · Page 1 of 1 (latest)

rain knot
#

been rlly stuck on this

#

very new rn lol

vestal python
#

global_basis is the basis ("rotation") of some node3d like the camera or a player model

#

so if you have a global_basis * Vector3.FORWARD, that's "forward in the direction this thing is facing"

#

and you might not want just that! You might have something with 2 axis movement, forward/back/left/right; that's more like:

var dir :Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")

var dir_in_space = global_basis * Vector3(dir.x, 0, dir.y)  
# so if the character is facing east and holds DOWN, this will move WEST...
#

anyway, that gets you a direction that you want to head in based on the keys pressed and the direction you're facing. You might want to scale it by the character's walking speed and assign it to velocity
Then your physics_process would do the rest by calling move_and_slide as it does now.

rain knot
rain oxide
#

You can use -global_basis.z as a shorthand for forward

#

But in any case I believe the solution here is to rotate your input direction by the camera's y rotation

#

So something like direction.rotated(camera.rotation.y)