Jump to content

April 2017 »

232425262728 29

Recent Entries

Recent Entries

- - - - -

Continued adventures in CharacterControlling

4: Adsense

Continued adventures in CharacterControlling 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 Posted Image

Victory or death!

Note: GameDev.net moderates comments.