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 / Non-Physics 3D collision

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Nov 2018 09:29
Is there any Non-Physics collision test for 3D objects?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Nov 2018 10:13 Edited at: 30th Nov 2018 10:15
Do you mean raycasting?

Example

//this checks for colliion between an object with any other object and returns its id
width#=(GetObjectSizeMaxX(object)-GetObjectSizeMinX(object))/2
height#=(GetObjectSizeMaxY(object)-GetObjectSizeMinY(object))/2
depth#=(GetObjectSizeMaxZ(object)-GetObjectSizeMinZ(object))/2

x#=getObjectX(object)
y#=GetObjectY(object)
z#=getObjectZ(object)
// calculate the start of the ray cast
start_x# = x#-width#
start_y# = y#+height#
start_z# = z#-depth#
// calculate the end of the ray cast
end_x# = x#+width#
end_y# = y#-height#
end_z# = z#+depth#
// determine which object has been hit
object_hit = ObjectRayCast(0,start_x#,start_y#,start_z#,end_x#,end_y#,end_z#)


There is alsorts of raycasting commands that basically cast a ray through an object to see if there is a collision
there is even

ObjectSphereSlide( objID, oldx, oldy, oldz, newx, newy, newz, radius ) which may be used for sliding collisions

for some reason the code tags don't seem to want to work
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Nov 2018 10:17
Will a raycast collide with a non-physics object?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Nov 2018 10:20
it will return an object id of any object in the area with collision mode on
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Nov 2018 10:22
Ok. I'll check it out. Thanks
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Nov 2018 10:25
Just sent you an example that I used in one of our game jams
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Nov 2018 10:27
Thanks matey. I'll check it out

Login to post a reply

Server time is: 2024-11-23 12:18:02
Your offset time is: 2024-11-23 12:18:02