Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sparky's and bumpy terrain

Author
Message
Infinity8
15
Years of Service
User Offline
Joined: 27th Feb 2011
Location:
Posted: 6th May 2011 14:59
I am using sparky's collision to add gravity and collision and stuff to my game, all of which works perfectly on flat ground/flat walls. (its based heavily on the example code)

Now i have made a simple peice of terrain in 3DS max, pretty much just a plane thats distorted to be bumpy. Now when i run on this the model slides around the surfaces like crazy, even though the bumps are hardly different from flat ground. And after a bit of sliding it just falls straight through the texture.

I treid removing sliding collision, but then my characater either just sticks to the bump, or just falls straight through.

Now my question is, how do you lot manage to code a movement system that allows you to walk over even terrain? also is there anything i may have missed whilst making the model in 3DS Max that would stop me falling through?

I can upload the code and texture if you want

thanks in advance if anyone can help
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 6th May 2011 15:37 Edited at: 6th May 2011 15:38
SC_SetupComplexObject() to setup your terrain.

Store your objects coords (old values)

Move your object (including gravity and falling)

Check collision (SC_SphereCast or SC_SphereCastGroup)

if there's a collision then retrieve the sliding values, otherwise use the new coordinates.

Your 3ds model shouldn't make any difference but if you can convert the model to .x or even .dbo then usually it loads faster.

Warning! May contain Nuts!
Infinity8
15
Years of Service
User Offline
Joined: 27th Feb 2011
Location:
Posted: 6th May 2011 15:42
:p thanks for the reply but ive already done this:

Setup terrain as complex object

calculate new positions from movement keys
spherecast to new position to see if intersects
if it does, check normals to see if slides: get sliding values, if it doesnt, just move it normally.
move object.

However it slides around like crazy

I also tried doing this:

check for collision using spherecast
if collide then get normals
if any of the normals are anything other than 0, then dont move the model in that axis.

This works fine for a while, but suddenly the character will just fall through the floor.

Ill post my full code in a minute, got to transfer it from my laptop.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 6th May 2011 17:27
You will need to use the SC_GetSlidingCollisionX() Y() and Z() to retrieve the sliding values. The normal values I'm assuming is the orientation of the face that's been collided with. If you're on the ground then checking the Y normal of a value between 0 and 0.8 should give you a slope on the ground.

To be honest each time I write my players code from scratch again something goes wrong somewhere until I find it... Player falls through the ground etc... But I do know you really only need to check the Y normal for ground slopes.

Warning! May contain Nuts!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 6th May 2011 18:09
Coincidentally I've been setting up Sparky's myself for the last few days, and it sounds like your sliding is a little to sensitive to the slope of the bumps.

I found this to work fairly well.

It checks the current position of the player, rather than the new position.


Group 1 is the terrain.

Login to post a reply

Server time is: 2026-07-11 02:37:02
Your offset time is: 2026-07-11 02:37:02