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 Studio Chat / Raycasting Issue

Author
Message
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 11th Apr 2020 21:20
Hello forum,

I want to simply detect the collision between two 3D objects and I do this mehtod, but it doesn't work. What am I doing wrong?

Thank you!

Code:

www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th Apr 2020 22:43
Hi MateiSoft . Take a look how I use collision in this little snippet I wrote in mi Chafari's trick thread . You can use your own textures to have a better look.

colli= ObjectRayCast(0,oldx#,oldy#-5,oldz#-5 ,x#,y#+5,z#)




Cheers.
I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Apr 2020 22:59
this function should help

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 12th Apr 2020 10:08 Edited at: 12th Apr 2020 10:16
Hi Chafari! Nice to see you! I'll have a look at your code soon, since I have to study it.

Hi Fubark! If I initialize it in the loop section, it always throws me the object that i added in the function objid. How can I initialize it? Let's say, object 1 to be the source of detection and the other objects, like 2, to be detected.

Thank you very much!
www.alexmatei.com
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 12th Apr 2020 16:31 Edited at: 12th Apr 2020 17:08
object_Hit = ObjectRayCast(objID2,start_x#,start_y#,start_z#,end_x#,end_y#,end_z#)
will return 1 or 0 depending on if objID2 is in raycast or not

I recall turning off collisions when you don't want an object to interfere that may be the present problem

try this

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 12th Apr 2020 20:52
looks like you almost got it, just get the new values before you move the object back again
i.e.
viewconex# = getobjectx(1)
viewconey# = getobjecty(1)
viewconez# = getobjectz(1)
MoveObjectLocalZ(1, 0.1)
MoveObjectLocalZ(1, -0.1) <----- move this
viewconenewx# = getobjectx(1)
viewconenewy# = getobjecty(1)
viewconenewz# = getobjectz(1)
**** <---- here
ObjectRayCast(0, viewconex#, viewconey#, viewconez#, viewconenewx#, viewconenewy#, viewconenewz#)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 13th Apr 2020 12:27
thank you for the help guys!
www.alexmatei.com

Login to post a reply

Server time is: 2024-03-29 08:43:52
Your offset time is: 2024-03-29 08:43:52