Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Collision Question; Can you have U3D return the ID....
Topic Started: Apr 16 2009, 11:25 PM (263 Views)
13bgarli
Member
[ *  * ]
Ok i have a problem, I can't seem to find out how to get U3D to return the ID of the collided Object.
this will help alot, i'm trying to incorporate bullets into my game. I got the Collision to work,
but i cant seem to get it to return the ID of the Object it collided with.
I'm useing U3D 2.1.1
:-/



thank you very much
Posted Image
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
You'll have to check the collisions within a loop, there's simply no other way.

If you have instances of the same object, you can use a with-statement to cycle through all of them. If not, you can store the different instance id's in a ds_list and use a for-loop instead.

In case there are multiple instances on the path of the bullet, you will also want to know which of those is hit first.

So your code could look like this:
Code:
 
var Closeness,Dist,Closest;

Closeness=90000;
//cycle through all object instances, to find the one colliding closest to
//the ray origin
with (object)
{
Dist=CheckRayIntersection(id,RayX,RayY,RayZ,RayLongi,RayLati);
if (Dist < Closeness)
{
Closeness=Dist;
Closest=id;
}
}

//if any instances collided with the ray, do something with the one closest
//to the ray origin
if (Closeness < 90000)
{
//do stuff with the Closest object instance
}
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
13bgarli
Member
[ *  * ]
Wow thankyou very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very, Much XD

I'll add you in the credits, i used one of your examples to. :D

Thanks MysteriXYZ
Posted Image
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
13bgarli
Apr 18 2009, 09:29 PM
I'll add you in the credits
Yay, I'm gonna be famous. Again :D .
Quote:
 
Wow thankyou very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very,very, very, very, very, Much XD
You're power(very,100) welcome ^_^ .
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply