GSFC_1 Posted January 11, 2018 Share Posted January 11, 2018 hey guys, got a high fast one thrown at me today, it involves collisions, which i have not been able to fully immerse myself into. We are learning to use leadwerks over here and we have set up a collision test. It involves a rotating box, with a "laser pointer" shooting a ray out of it. there are 3 other boxes on the floor, each sitting pretty, doing nothing. When the laser pointer spins, the laser eventually contacts the surface of the box. This causes the API to change the color of the collided-with box, to red. This is what we wanted. The second the laser touches the box, it changes color to red, but after the laser pointer is no longer in contact with the box, the box stays red. We want the box to change back to iits original color. Its as if the collision system needs to be reset? Is that the case? Standby, my co-worker will send me the code he has been working on . Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted January 11, 2018 Share Posted January 11, 2018 i hope i understand your problem correctly. But as i see it, you would have to manually set the color back to its original color. Quote Link to comment Share on other sites More sharing options...
GSFC_1 Posted January 11, 2018 Author Share Posted January 11, 2018 ya, I think I am starting to realize this. The color change needs to be configured to be momentary. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 11, 2018 Share Posted January 11, 2018 You could make an EnterExit trigger. Not sure if you are using Lua, but you could be doing something similar in C++. Script.enabled = true Script.entered = false Script.exited = false Script.collided = false function Script:UpdatePhysics() if self.enabled then if self.entered then if self.collided == false then System:Print("Exiting the trigger") self.exited = true self.entered = false end end self.collided = false end end function Script:Collision(entity, position, normal, speed) if self.enabled then self.collided = true if self.entered == false then System:Print("Entered the trigger") self.entered = true self.exited = false end end end 1 Quote Link to comment Share on other sites More sharing options...
GSFC_2 Posted January 12, 2018 Share Posted January 12, 2018 I think I complcated the issue by trying to change colors. The problem simplified is this: I have a long slender box that I rotate with this line of code self.entity:Turn(0,.5,0) Then I check for collisions with other objects. function Script:Collision(entity, position, normal, speed) myname = entity:GetKeyValue("name") System:Print(myname) end This prints the name of each object that collides with the long box. Works perfectly. Once. As the box rotates around and collides with the objects a second time nothing happens. I tried AggorJorn's code and it does the same as mine. It prints "Entered the trigger" and "Exiting the trigger" for each object once. Subsequent collisions are ignored. It appears after an object has recorded a collision something needs to be reset before the next collision. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted January 13, 2018 Share Posted January 13, 2018 When you use commands like Turn, Move, SetPosition, etc. you are overriding the physics simulation. The correct way to do this is to use a kinematic joint, which allows you to set a target position or rotation, and it uses physics forces to acquire that orientation. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 13, 2018 Share Posted January 13, 2018 I'm going to add a new overload to Entity:GetDistance() like this: float Entity::GetDistance(Entity* entity, const bool useshape) If useshape is true it will find the closest point between the two entities using their collision shape. When this is equal to zero, the entities are intersecting. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 24, 2018 Share Posted January 24, 2018 Should be in there now, beta branch only. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
GSFC_1 Posted January 24, 2018 Author Share Posted January 24, 2018 Ah, thank you josh. Quote Link to comment Share on other sites More sharing options...
GSFC_2 Posted January 26, 2018 Share Posted January 26, 2018 what about professional standalone update? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.