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.

AppGameKit Classic Chat / Physics objects and 3D RayCasting/SphereSliding

Author
Message
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Apr 2016 22:59
Ok, are physics object included in the RayCasting/SphereSlide commands, as nothing I've tried will work.

I have an object, with which I've used the Create3DPhysicsStaticBody command to create my physics scene. I want to have collision detection on a third person camera by position the camera at the players head position, getting the coordinates, moving the camera backwards, then sphere sliding with the two sets of co-ords.

I've tried the ObjectRayCast and GetObjectRayCastDistance commands, the Get3DPhysicsRayCastClosestContactPosition command, the ObjectSphereSlide command, RayCast3DPhysics and Get3DPhysicsRayCastFraction as well as a few others.

Nothing is working.


HELP!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 3rd Apr 2016 02:04 Edited at: 3rd Apr 2016 02:06
If you are creating your static world/level with Create3DPhysicsStaticBody() then you would need to use the 3D physics commands on this page for ray casting.
https://www.appgamekit.com/documentation/Reference/3DPhysics.htm
The other ray casting commands do not work on a physics object created with commands that have the words "3D physics" in the name.

Quick example
The coffee is lovely dark and deep,and I have code to write before I sleep.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Apr 2016 14:06 Edited at: 3rd Apr 2016 14:08
I am...



See here. Your example is way different to mine. (perhaps because there are no examples in the help files...)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Apr 2016 15:09 Edited at: 5th Apr 2016 16:55

Tried this. Again, nothing.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 5th Apr 2016 16:45
I do not have time at the moment to code a camera collision function.
There may be some errors in your example look at line 2 the variable names are just a #.
Also the ray needs to be cast from the cameras position to a world vector a certain distance
from the camera. When you get a hit just reposition the camera at its position.
Also Get3DPhysicsRayCastContactPosition() returns a world vector contact position on the object hit.
You would not want to position the camera at that location. I left the command in the example to
show how ray casting works and the results it returns.
You will of course need more than one ray in different directions but that is up to you to code.
There is no need to create and delete the rays and vectors every time just reuse them.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Apr 2016 17:10 Edited at: 5th Apr 2016 17:19
Quote: "I do not have time at the moment to code a camera collision function."

I'm not asking you too, but if the help files had actual working examples I could figure it out for myself. But they don't, so I can't. I don't mean to sound rude, and I apologise if I do, but I and others paid for AppGameKit, and there is a lack of information or examples provided. I know you're slowly adding examples, but not for this issue.

Quote: "There may be some errors in your example look at line 2 the variable names are just a #."

That's a code blocks error when pressing Ctrl + delete. I've already fixed that in my actual code (and the snippit above), they are Y1# and Z1# respectively.

Quote: " the ray needs to be cast from the cameras position ....."

it is. (Even though I've moved the camera to the final position)
X1#, Y1# and Z1# are the (old) cameras position.

Quote: "to a world vector a certain distance from the camera"

You used :

I don't understand this. Do I need to use trig to get these values? I just moved the camera backwards to that certain distance away to get the end point of the ray. Can't I just use these two position vectors? (Pre-camera moving, and post camera moving) If need be, I could just normalise these two vectors to get the distance from the original vector.

Quote: "Also Get3DPhysicsRayCastContactPosition() returns a world vector contact position on the object hit.
You would not want to position the camera at that location. I left the command in the example to show how ray casting works and the results it returns."

I tried running your version, it didn't work as expected.

Quote: "You will of course need more than one ray in different directions but that is up to you to code."

Why? The camera should move directly backwards until it hits something, or reaches the specified distance away from the player.

Quote: "There is no need to create and delete the rays and vectors every time just reuse them."

I know, I just didn't want to keep track of the IDs whilst testing. If I eventually get a working version, I can clean it up afterwards.

Login to post a reply

Server time is: 2024-11-25 08:44:56
Your offset time is: 2024-11-25 08:44:56