I need some help understanding vectors, movement, quaternions, and rotation in my game. In the images below I’ve mocked up what I’m trying to accomplish. The mockups are third-person but the in-game camera uses first-person perspective.
I would like the player character, as denoted by the capsule and attached camera below, to walk forward (using standard WASD) along a path until they reach a wall. When they are close enough to the wall in front of them they can activate a control that will alter their faux gravity so that they are now pulled “down” in the direction they were previously facing. The player can then proceed to walk “forward” along their new rotated axis.
The game world will have cubes in every 90 degree direction, so this would need to be a universal solution that could apply to any vector direction. The cubes and the player should always maintain right-angle symmetry to one another.
I would like input on the best way to approach this problem.
User raymix posted about using faux gravity in another thread and that is generally what I want to do (I think). This lead me to use alex.loren’s package that he posted in the big Faux Gravity thread.
I’m using the RigidbodyFPSWalker script. Is that the best option for this kind of thing or should I use something else?
I’m able to rotate the character using:
transform.Rotate(-Camera.main.transform.right * 90f, Space.World);
However, after doing that I’m no longer able to walk “forward”. The RigidbodyFPSWalker walker script still reacted as if I hadn’t rotated. “Forward” was still moving back and forth along the Z-axis, for example. After rotating, I would want “forward” to move along the Y-axis, like in the images below.
- Is there a simple way to get the “up” vector from the side of a cube? For example, I could easily raycast and get the cube in front of me, but would that even help me?
Any other advice you can give me would be greatly appreciated. Please let me know if I can clarify anything.