Jump to content
  • Advertisement
  • entries
    743
  • comments
    1924
  • views
    582651

Continued adventures in CharacterControlling

Sign in to follow this  
Aardvajk

782 views

Somewhere in a dark corner of Eastern Europe, there must be an asylum for programmers who have dared to try to implement a robust character controller. Listen - you can almost hear their pathetic mewling. Poor, lost souls, doomed forever to crouch in the corner of filthy cells, doing trigonometry on the walls with their own faeces.

I shall soon be checking in, no doubt. Its getting bad. Really bad.

But we are making progress. I have a sort of stable character controller working now. Actually the only major problem left to solve is sliding down slopes while you are pushing into them. I've managed to stop you from climbing up slopes above a certain angle which is a big win.

Its a solution borne more of trial and error than sound maths. I did try to work it out theoretically but nothing seemed to work.

The problem, in a nutshell, is that when you intersect a slope, the minimum translation vector you get back from the collision system (GJK in this case but would be the same with SAT) is pointing up slightly, as the slope normal is doing the same. This means that when you resolve a collision into a sloped surface, the result pushes you up the slope slightly.

I've been playing with various ways to fix this using clever trig but nothing worked out, but I have discovered that, due to a number of odd corner cases, it was necessary to re-lock the character to the floor after all the other complicated stuff going on, at the end of the update, using a ray-cast and the distance from last journal entry to figure out the position on the floor based on the angle of the slope.

Turns out that as long as the threshold for this lock is set slightly higher than I ideally wanted, it actually takes care of the slope climbing problem quite nicely. The GJK separation vector moves you up slightly, but they you get snapped back down again into what looks to be the correct position.

I've set up a couple of inputs to make every shape in the world rotate so I can test a variety of surfaces and it seems to behave correctly. The main omission now is that if you push into a steep slope, you stay put rather than getting dragged down by gravity - I want you to fall down the slope at the same speed as you would without pushing into it.

But progress anyway. Pleased to see that I can rotate the world and it all still seems to work, although I've been testing on a level slightly rotated to the left so long now, the real world looks slightly wonky to me smile.png

Victory or death!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!