I am so frustrated atm. I cannot seem to get down wall running.
I am trying to achieve something like this>
The process I have so far goes something like this:
*Walks near wall
*Player has collider that detects when near walls
*FSM checks if player is Grounded and near a Wall
*If both conditions are met then player is rotated by 90* so feet are on the wall and gravity is turned off
The issue comes in when the conditions are met and the character attempts to rotate then they are flung in a random direction like there is something wrong with the physics.If it has any relevancy then I should also let you all know that I have the rigid body attached to an empty body and the child of that is the player whose animations use root motion with a collider attached to the play so they dont fall through the ground.
I dont know what I am missing.
Edit:
So after many different ways of detecting when I am near a wall, I decided to go with a raycast facing the front of me. The issue I am facing now is:
*Getting the character to rotate the right direction [with his feet on the wall] regardless of the angle of the wall.
TLDR: Find a way to calculate what direction I am from a wall regardless of what WORLD SPACE the wall is at and turn my character to stand on that wall.EDIT 2: Thanks for the answers below. I am so close to getting this down after revising the way I do wall running. The issue I am having now is getting the direction I am facing to the wall. What I mean by that is, if I am on one side of a wall then I need to apply gravity to the Z axis to stick to the wall then have my X and Y free so I can move around on that wall freely. The same is said about the other sides of the wall with X being replaced with Z. Another issue with that is that some sides use X or Z but it is - so I would need to invert the controls but I would first need to be be able to tell what direction of a wall I am on or facing then I assume I would float compare based off what direction then change the translate variables based on the sign and axis.
EDIT 3: So I ended up solving the issue. The way I was going about doing wall running was, in my case wrong. All I needed to do was:
*Smooth Look At
*Get YZ axis and feed that as a vector3 into translate and have translate on Self Space so no matter what side that it will still use the same inputs in the same directions.
*I had an issue with the rigid body and my character moving ever so slightly so I have set velocity to 0 when im on the wall and translate myself forward so that I am always sticking to the wall.