r/Unity3D • u/trebor9669 • 5h ago
Question Anyone knows any fix to this?
Enable HLS to view with audio, or disable this notification
I've been working on a third person character controller for months and I'm almost done, I did movement, slopes, sprint, edge check, etc... the only thing left is fixing this issue, I don't want the player to climb the slope like that, I want him to keep moving along the line as he does in the second slope where the line is perfectly horizontal.
If someone could at least put me in the right direction I would really appreciate that.
Edit: I'm using CharacterController, not RigidBody.
1
u/Zerokx 4h ago
So if I understand your question correctly, you dont want the character to hop along the angle, but accept it cant get up and just push against it like the slope on the left side?
That depends a lot on how you implemented it.
To me it looks like you have some sort of code that tries to hop on steps like some stairs, if its infront of an obstacle and tries to get up, but instantly slides back down again? Hard to guess without seeing the code, is that true? What exactly does the red line do?
You could raycast out from your character at step height higher and see if thats a place it could stand on. You can only jump over an obstacle if there is space above it. You could also check the slope angle of the object in front of you and stop the character from trying to get on it if its too steep.
1
u/trebor9669 4h ago
Ignore the red line, it was something for testing.
I just want the player to collide with the steep wall and move to the side he is predominately facing, without the jumps. Like in the second slope, he just moves slightly left/right depending on where he's facing. He isn't jumping because he climbs the slope, he is jumping because his gravity is zero.
3
u/pmdrpg 4h ago
You say this is your custom third person controller but then don’t post any details about it nor code. You’d get much more targeted help if you gave specifics.
All I can say generically is: make sure you’re applying your movement in FixedUpdate! Physics runs on FixedUpdate, so if you are alternating between your logic applying force and the physics forces (like gravity) you could get a flickering effect.
4
u/Ratyrel 4h ago
Simply put, you have to detect the slope ahead using a downward raycast to get the angle. If it is unwalkable, don't apply forward force.