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 / Falling through maps sc spherecastgroup

Author
Message
misifield
18
Years of Service
User Offline
Joined: 23rd Nov 2007
Location: ohio
Posted: 7th Jul 2011 04:12
I am having a problem with sliding collision. I used the sliding demo code as a base to work off of that comes with sparkys dll. My model is fine running on the maps and jumping but if it walks up a slope that is to steep he will not slide he just falls through the map. Also the model I am using does not stop near the edge of the objects, his limbs and half of the body enter the object before stopping. I changed the slope in the demo and that object will fall through the map as well. Does anyone know how to fix this and to stop a close to an object so the limbs do not go inside. Thanks for the help and here is the code.


mfield
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Jul 2011 10:04
First thing, maybe that sphere size isn't big enough? - you have it set to 0.1 units - if that was bigger, it might stop your limbs going into walls as well as making the level collision more robust.

One thing that might be worth trying, is doubling up your slide collision check, like:

Where you have...



Have this, to check both directions:



Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Jul 2011 18:33
Hey I never thought of that, nice idea VanB

misifield
18
Years of Service
User Offline
Joined: 23rd Nov 2007
Location: ohio
Posted: 8th Jul 2011 06:33
Thanks Van B

I was able to stop my model from falling through the map by using getstaticcollisiony instead of the sliding collision when checking for slopes.


I changed the radius of the sphere object when checking collisions. After I did that my model jumped around a little and fell through the map again.


I tried to mess with it some and used the suggestion that you had if collide=0 then check the opposite side. Why would I want to check the opposite side? Is this to check for a collision if the player is walking backwards?

Do you have any other suggestions to stop my model further back from an object?

mfield
miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 11th Jul 2011 23:37 Edited at: 11th Jul 2011 23:38
You position your actor using some kind of a speed# (Jump#, Gravity#) variable. If you go for example 50 units in a direction, and you move into ( or fall under ) your scene deeper than spherecast radius, that kind of collision wont work.

You have to make a raycast into the direction you are moving (from the actors current coordinates to the expected arrival coordinates).

If hit occours, then it means that you will hit ground or wall earlier before reaching the expected coordinates.

In this case you mustn't position your actor to a lower y than the arrive point ground height-(spherecast radius/2).
(it helps not to fall under your scene, but yet doesnot tilt you to jump out, but the method is the same for walls and tops )
After this reduced reposition, you may call for spherecast check.

Another (and truely not the best) solution, if the maximum movement speed in any direction at any time is smaller than your spherecast radius.

(if you have a spherecast radius# of .5, and you want to move 0,-5,0 then you may reposition and check spherecast collision 10 times moving 0,-0.5,0) before sync.

I hope I was clear, I'm not a native english speaker.

No place like 127.0.0.1 .
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 12th Jul 2011 00:13
I always use 2 checks.

1. In the direction the character is moving, check from the previous position to the new position. The result becomes your new X and Z position.

2. At the new X,Z position cast from above the character, to below the ground. The collision point is your new Y value.

This should prevent you from falling through, and gives you the option to go back to sliding collision for the first one, and a quick raycast for the second.

Login to post a reply

Server time is: 2026-07-10 21:41:57
Your offset time is: 2026-07-10 21:41:57