Charrua Posted November 30, 2016 Share Posted November 30, 2016 is there a function to get a list of entities that are above another, in contact, physically speaking. When an entity collides another a collision is detected an i can test for collision but after a while stop bouncing and collision stops also. What i need is to know which entities remains in contact. I can do a aabb test or keep track of entities that has been collided.. but all has its pros and cons, is there a physics way of testing entities actually in contact? thanks Juan Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Josh Posted November 30, 2016 Share Posted November 30, 2016 This is tricky because if an object is at rest, it theoretically is not in contact with anything. Otherwise it would experience a force pushing it away and would not be at rest. The engine does not store lists of previous collisions because it would just be a lot of data that is mostly never used, and add a lot of complexity when entities are deleted. There is a function to gather all entities in a bounding box, but what specifically are you trying to do with this? Maybe we can help. 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...
gamecreator Posted November 30, 2016 Share Posted November 30, 2016 The list seems like the way to go. I think you could just check if an entity collided with something the turn before and if it's at rest now, it's probably safe to assume it's still colliding. Quote Link to comment Share on other sites More sharing options...
Charrua Posted November 30, 2016 Author Share Posted November 30, 2016 thxs i'm implementing a "conveyer belt" (kind of) and it hast 3 states: forward, backward and stop while in forward or backward any entity colliding with it is moved and as it is moved it remains colliding and so the belt woks as spected. If i stop motion, then.. entities stop colliding the belt and then, when i need to restart movement, i need to know which entities remains over it. Some entities may finish colliding because they reach the end or slide outside the belt (for any reason) so having a historic of entities collided (recently) is not a bad idea but isn't sure that this list is will be correct all the time. One of my ideas was use an aabb and is still the one i guess will use but before i needed to ask .. just in case here what i'm doing currently: (the other cars will have other uses, forklift and the like) having some spare time so i decided to enjoy a little. https://dl.dropboxusercontent.com/u/78894295/leadwerks/conveyor%20belt%202.mp4 https://dl.dropboxusercontent.com/u/78894295/leadwerks/conveyor%20belt.mp4 @gamecreator, i was posting as you did your, the list is not a bad idea, but there will be no garanties, i mean, a box should be pushed away or lifted from one belt to other place and will, perhaps, remains in a list... Juan Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Rick Posted November 30, 2016 Share Posted November 30, 2016 Maybe something like: Box.lua Script.entered = false Script.exited = false Script.hadCollision = false function Script:Start() self.collidedBelt = nil end function Script:UpdatePhysics() if self.entered then if self.hadCollision == false then if self.exited == false then self.exited = true self.entered = false -- we aren't colliding with anything so we are either at rest (maybe) or falling if self.collidedBelt ~= nil then self.collidedBelt:RemoveItem(self) self.collidedBelt = nil end end end end self.hadCollision = false end function Script:Collision(entity, position, normal, speed) self.hadCollision = true if self.entered == false then if entity.script ~= nil then if entity.script.isBelt ~= nil then self.collidedBelt = entity -- add ourselves to the belt so it knows it has to push us around entity.script:AddItem(self) end end self.entered = true self.exited = false end end Quote Link to comment Share on other sites More sharing options...
Charrua Posted November 30, 2016 Author Share Posted November 30, 2016 i'm at work now, i'll give it a try later, thanks i was thinking belt side, you are thinking box side.. Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Rick Posted November 30, 2016 Share Posted November 30, 2016 Yeah I figured the box can tell what it collided with so if it's a belt it tells the belt to add it to the belts list and when it stops being that specific belt it's able to tell that belt to remove it from its list. Things in games are almost always backwards from what you'd think in real life. Quote Link to comment Share on other sites More sharing options...
Josh Posted November 30, 2016 Share Posted November 30, 2016 The best way to do this might be to create an invisible box above the belt. In the object's collision function, apply force to any object that collides with it. Use the trigger collision type so it acts like a force field. You might be able to do this in the collision callback of the belt. When a collision occurs, try adding a force or adjusting the velocity of the colliding object. If i stop motion, then.. entities stop colliding the belt and then, when i need to restart movement, i need to know which entities remains over it. Get all entities in an AABB and add a force of (0,0,0) to each to wake them up. 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...
Charrua Posted November 30, 2016 Author Share Posted November 30, 2016 You might be able to do this in the collision callback of the belt. When a collision occurs, try adding a force or adjusting the velocity of the colliding object. i'm basically doing it, but didn't figure out how to "wake up" entities over the belt when at rest. this is my current belt's collision code: function Script:Collision(entity, position, normal, speed) --self.stateValue may be -1:backward, 0: stopped, 1:forward --self.speed is a factor to adjust belt speed if self.stateValue~=0 then rot=self.entity:GetRotation(true) --belt orientation vel=Vec3(0,0,0) vel.x = Math:Sin(rot.y)*self.stateValue*self.speed --get x,y components of orientation vel.z = Math:Cos(rot.y)*self.stateValue*self.speed entity:SetVelocity(vel) --applya velocity to entities that collide with the belt end end guess now has some other ideas, apply a 0,0,0 force to wake up never cross my mind and the invisible trrigger thing.. have to give it a try also.. as always it's a matter of find a nice solution doing some tricks in between to get good results with few resources.. thanks again Juan 1 Quote Paren el mundo!, me quiero bajar. 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.