#3D game movement

2 messages · Page 1 of 1 (latest)

hushed panther
#

I'm making a 3D game, and I'm pretty much done with my characters movement. However, I an running into a simple issue. I have a Vector3.NULL system set in with velocity and gravity formula relying on it, and as a result I have a basic movement system to maneuver the character in all 3 axis. However, I recently added the ability to rotate the character and his view around so you could move around in all 6 directions relative to the way you are facing. With my system in place, it simply moves in the cardinal directions independent of what directions the player is facing, making movement super awkward and unintuitive if you try to move your camera. Any tips of what system I could put into place to make it so the player moves relative to his front, rather than true pos/negative x, y, and z? I was thinking of using the ".move_toward" function, with a point in all 4 sides of the player that it would move towards, and these points would move and rotate with the player (though this means rewriting all my movement options such as my dash and teleport and such); I was also thinking it would be possible to make a formula that adjusts the x to z ratio of movement depending on how many degrees you have turned, but I'm not that good at math and wouldn't know where to start with that. Are there any more obvious/elegant solutions to my issue that would help make a streamlined and fluid 360 degrees movement system that you guys can think of?

#

I might end up just using the distance formula, but any more simple and less mathematically inclined versions would be great