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 / float Get3DPhysicsRayCastFraction( rayID ) appears to always return 1

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Dec 2018 22:30
I must be doing something wrong. I usually am
See attached project

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 12th Dec 2018 22:33 Edited at: 12th Dec 2018 22:35
You never done anything wrong (look at your Kart product) - maybe unsure of what the command does and what it achieves.

What is your trying to acheive
puzzler2018
User Banned
Posted: 12th Dec 2018 22:54
Maybe you want to Clamp down a value from what ever down to 0.0 and 1.0

Clamp is such a useful function

Does anyone have the formula at all
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Dec 2018 23:13 Edited at: 12th Dec 2018 23:14
The function should return a value between 0 and 1. Which is, I assume, the distance (0=start of ray, 1=end of ray) along the ray where the collision occurred.
Currently it is ALWAYs returning 1
puzzler2018
User Banned
Posted: 12th Dec 2018 23:15
have you set the variable to return to as a float?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Dec 2018 23:29
Yeah. Been bitten by that bug too many times
puzzler2018
User Banned
Posted: 12th Dec 2018 23:32
That ok then ?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Dec 2018 23:34
Nah. Still returns 1. Should return a fraction
puzzler2018
User Banned
Posted: 12th Dec 2018 23:41
Please write the code on that one line
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Dec 2018 00:43
The project is there for you to download matey. Download it and you will see
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Dec 2018 02:14 Edited at: 13th Dec 2018 02:17
Hey blink0k,

use this:
cast = RayCast3DPhysicsObject( ground, ray, fromVect, toVect, 0 ) the 0 makes a difference. No idea why.

This results in .5

Your start ray is at -4. Your end ray is at 3. Which means your ray is 7 units long.
Your ground starts at y = -.5 and ends at y = .5 with a center of y = 0. I believe only faces will be hit. So the 0 is irrelevant.

Your ray is 7 units long, and hits the ground at 3.5 units(at y=-.5), which is 1/2 of the length of your ray, or .5 units.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Dec 2018 02:47
Thanks Golelorn dude. You are a savior matey!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Dec 2018 03:20 Edited at: 13th Dec 2018 07:43
integer RayCast3DPhysicsObject( objID, rayID, fromVec3ID, toVec3ID, allOrClosest )

Why does it ask for an object if it going to return any object that is hit? What is the purpose of giving it an object? It seems redundant to me

it even says "Cast a ray and checks against the object"
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Dec 2018 13:18
I believe if you use the 1 option you can then use Get3DPhysicsRayCastNumHits() and Get3DPhysicsRayCastContactPosition() to determine various collision points on the tested object. Just like the normal ray commands.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Dec 2018 20:21
Yes but why is it returning collision with OTHER objects?
puzzler2018
User Banned
Posted: 13th Dec 2018 20:36 Edited at: 13th Dec 2018 20:42
Forgive me but where are you assigning "ray"??

EDIT

ignore me,

ray = Create3DPhysicsRay()

My mind boggles with this one
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 15th Dec 2018 15:33
Quote: "integer RayCast3DPhysicsObject( objID, rayID, fromVec3ID, toVec3ID, allOrClosest )
Yes but why is it returning collision with OTHER objects?"


Perhaps in the alternative form it's only testing and then returning the object closest then stops testing, instead of continuing checking everything it could encounter between from and toVec3, which behind the scenes might be faster then testing for all available physics objects?

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Dec 2018 21:23
But what is the point of passing the object to the function?
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 16th Dec 2018 12:23
Ah, I see what you mean now.. Perhaps otherwise it would falsely detect the objects own boundaries if changing during it's animation?
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Dec 2018 01:52
I'm really wondering if there is some kind of bug in the raycasting currently in AGK2, because I'm getting similarly confusing results with the normal raycasting using a '0' to detect all objects. For some reason that doesn't work reliably, however using a specific objID does. It didn't behave this way previously as far as I can tell.

Quote: "Perhaps otherwise it would falsely detect the objects own boundaries if changing during it's animation? "


I'm almost certain this is something we need to handle with our own code.

Quote: "
Cast a ray and checks against the object.
Definition
integer RayCast3DPhysicsObject( objID, rayID, fromVec3ID, toVec3ID, allOrClosest )
Parameters
objID - Id of object to check against.
rayID - ID of the ray
fromVec3ID - ID of the starting point vector. Create a vector with the CreateVector3() command.
toVec3ID - ID of the destination vector
allOrClosest - 1 = all contacts, 0 = closest contact
"


Quote: "But what is the point of passing the object to the function?"


Maybe it is to force the object to be 'active' so it won't be accidentally ignored for a ray trace?
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Dec 2018 01:53
Come to think of it... we could really use some better explanations for the ray tracing commands.
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 21st Dec 2018 17:04
Documentation indeed isn't always clear on these maters..

Maybe anybody from AppGameKit Team could enlighten us? - Paul perhaps?

Login to post a reply

Server time is: 2024-11-23 09:10:47
Your offset time is: 2024-11-23 09:10:47