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.

Dark Physics & Dark A.I. & Dark Dynamix / Ray casting with dark physics? (Detecting floor)

Author
Message
Dewi Morgan
16
Years of Service
User Offline
Joined: 16th Jan 2008
Location: London, UK
Posted: 28th Feb 2008 01:10 Edited at: 28th Feb 2008 04:39
I am trying to detect whether the player is standing on the floor or an object (so they can jump) or is in the air.

I have searched the forums and read the docs and found that to do raycasting in dark physics, I need to use one of two undocumented commands:

[Edit: Now I have it working, I've edited the following so that other people searching have a reference]

Method 1: phy ray cast closest shape()
WORKS. Undocumented command, though is syntax-highlighted. Used in the "ProjectsDark PhysicsDemosRigid BodiesRay CastingRay Casting.dba" demo.


Method 2: phy ray cast all shapes()
WORKS. Undocumented command, mentioned in the documentation under "phy get ray cast hit()", and is syntax-highlighted. Used in the "ProjectsDark PhysicsTutorialsRay CastingRay Casting.dba" example. Possibly less efficient than the above since it will enumerate all colliding objects rather than just the first.


Method 3:
FAILS. Undocumented command, described in the update thread http://forum.thegamecreators.com/?m=forum_view&t=119906&b=30 but that's about it. Can't get this one to give a stable result. Works sometimes, but acts in the Z direction at other times. I may be using it wrong.


Method 4: phy get collision
FAILS. Undocumented command. Unfortunately, always returns false for a player controller, maybe because it is automatically moved so's not to collide with anything.


I find it amusing that the only ways to do this are with commands that are missing from the docs.

Yet another game programmer
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 28th Feb 2008 03:13
your doing it wrong.

it works on vectors.

0,1,0 should be straight down.

try that.

good luck.
Dewi Morgan
16
Years of Service
User Offline
Joined: 16th Jan 2008
Location: London, UK
Posted: 28th Feb 2008 03:43
Thanks. Will test it with the above commands, and will edit them if working, for anyone searching in future.

Yet another game programmer
Dewi Morgan
16
Years of Service
User Offline
Joined: 16th Jan 2008
Location: London, UK
Posted: 1st Mar 2008 08:55
[The commands did work and I did edit, thanks!]

I just spent a day and a night (re-)learning about quaternions, vectors, and other fun stuff, so that I can find the right points to raycast up from in order to detect: whether the player needs to autocrouch because of a low ceiling; and whether they can straighten up if they are crouched.

I think I figured out how to do it. However, raycasting is the wrong solution anyway.

The first test would be better done by doing collision detection with a player object at their destination point: but how would I do this? (I have Dark Physics, so it feels like something that should be easy, but I can't figure out how... much like most things in DP!)

The latter would be better done by doing collision detection with a player object that was taller than they currently are: should be much the same code as the above, if I could just figure out how.

Anyone able to throw me a clue?

Yet another game programmer
sindore
19
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 2nd Mar 2008 11:09 Edited at: 12th May 2008 02:56
I`ve added a link to my raycasting post, have a look at my 1st go at raycasting.

http://forum.thegamecreators.com/?m=forum_view&t=127692&b=30

soul sucking devils, twisted body of the damed, slivering slim drips from ever poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!....

Login to post a reply

Server time is: 2024-05-20 01:27:16
Your offset time is: 2024-05-20 01:27:16