Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






Continued adventures in CharacterControlling

Posted by Aardvajk, 25 April 2014 · 309 views

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!




November 2014 »

S M T W T F S
      1
2345678
9101112131415
16171819202122
2324252627 28 29
30      

Recent Entries

Recent Comments

Recent Entries

Recent Comments

PARTNERS