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 / [SOLVED] 3D collision detection

Author
Message
dbenv9
6
Years of Service
User Offline
Joined: 24th May 2017
Location:
Posted: 24th Dec 2019 13:41
Is there any function that detects me if an object collides with another object? Something like: "getCollision(obj1,obj2)", or something similar.
(In my project I use .obj models and I haven't enabled physics)

The author of this post has marked a post as an answer.

Go to answer

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Dec 2019 14:59
the following function checks if an object has collided with another object and returns the object id


if you change this line

to

it checks if objID collides with ObjectID2
MerryChristmas Everyone
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
dbenv9
6
Years of Service
User Offline
Joined: 24th May 2017
Location:
Posted: 24th Dec 2019 21:50
Thank you very much for the answer, but in this way the collision is only detected along one line, and not on the whole 3D object. Is there a slightly more precise method?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Dec 2019 22:12 Edited at: 24th Dec 2019 22:40
This post has been marked by the post author as the answer.


If your program uses physics
https://www.appgamekit.com/documentation/Reference/3DPhysics/GetObject3DPhysicsContactObjectB.htm

which is more accurate
MerryChristmas Everyone
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
dbenv9
6
Years of Service
User Offline
Joined: 24th May 2017
Location:
Posted: 25th Dec 2019 12:13
Ok, thanks
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 28th Dec 2019 06:56 Edited at: 28th Dec 2019 07:07
Quote: "Something like: "getCollision(obj1,obj2)""

in case you're not working on a full-blown 3d physics project, there IS an easy way to return whether or not 2 objects are colliding but it does use a few commands from the 3d physics command set:


specifically: GetObjects3DPhysicsContactPositionVector()

fubarpk's GetObject3DPhysicsContactObjectB method above is generally more involved, cycling through potentially numerous contacts, extracting object #'s, etc.. it will work the same but if you're looking for getCollision(obj1,obj2) behavior, i'd keep it simple.

Login to post a reply

Server time is: 2024-04-25 14:38:39
Your offset time is: 2024-04-25 14:38:39