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.

DarkBASIC Professional Discussion / Intersect Object not reliable

Author
Message
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Nov 2015 05:27
Try to make 2 objects 1 positioned on 1 side and one on the opposite side, make a third object and let move it with upkey downkey to move forward and backward, and rotate it with the mouse.
If I go between the 2 objects (which I need to intersect with the 3rd one), the intersect value flickers, even standing on a fixed point and just rotating the object, so that in 1 rotation could trigger for example a 15 distance value, and rotating it a bit more it returns 0, that means no intersection.
Why this happens? I have tried also to make bigger collisions for the 3rd object but nothing happens, tried also to higher or lower 0.1 or 0.5 the y values but that way the intersect value is Always 0.
All the 3 objects are exactly on the same height.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 2nd Nov 2015 10:02
Not sure what happens, probably it flickers between the 2 intersect check values and 0
I had similar occurances in the past but can't remember what code I was using.
Try the attached code.
The only problem I have in this one is that if speed is too high i miss the collision
Let me know how it goes for you
Cheers
Scorpyo

Attachments

Login to view attachments
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Nov 2015 16:57
I think I will make a workaround making a cube object and stretching it from 1 object to the other, checking the collision with the 3rd object. And if I will see problems due to the eccessive speed of the 3rd object I will try to check multiple times the collisions moving back the 3rd object, and then restoring it forward after the collision check.
It's a shame because if the intersect object worked fine I could do the check with 1 code line only.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 2nd Nov 2015 18:24
Don't forget that intersect object works on raycasting from one point to another, it's not like box collision.
the intersect value is the value of the ray length in that direction when it hits an object.
It has nothing to do with 3D objects intersecting each other
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Nov 2015 18:53 Edited at: 2nd Nov 2015 18:54
exactly, when it hits the object, that's what I need, but why the same object in the same position have a flickering value just rotating it?
All what I need to know is if the 3rd object pass between a line projected from object 1 and object 2
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Nov 2015 19:54
I ve ended up using a temporary object positioned between object 1 and 2 to check the collision against object 3(correcting size and rotation based on the other 2 objects positions and distance), works perfectly.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 2nd Nov 2015 20:01
Here I am raycasting between the two static cubes and it reads the right values even if i rotate the movable cube
0 if the moving cube is out of the way and some value when it's in between the static cubes

Attachments

Login to view attachments
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Nov 2015 20:29
I see you are not using collisions, so the intersect command check the 3rd object polygons and not the collision? Maybe that is what caused the problem because the object I am using is very small on the Y size. I think I will keep my workaround as seems more reliable and I can change collisions sizes if needed.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 2nd Nov 2015 23:52
Here it is with collision checked and implemented

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-29 14:31:22
Your offset time is: 2024-03-29 14:31:22