thehankinator Posted November 2, 2015 Share Posted November 2, 2015 I have a script that places traps. I don't want to the player to be able to lay the traps on top of each other so I call ForEachEntityInAABBDo in the space the trap would take, if there isn't anything there I place the trap. The problem I am running into is if I place a trap to the left then another to the right I cannot place one in the center because both the left and right trap are returned by ForEachEntityInAABBDo. If I do a IntersectsAABB check in the ForEachEntityInAABBDo callback I can confirm that the AABBs do NOT intersect. I've verified that the parent for the entities is nil. I've tried calling UpdateAABB (with all the options). Is it possible that there is something special about loading a prefab from a script when it comes to hierarchy and ForEachEntityInAABBDo? Check code: world:ForEachEntityInAABBDo(self.entity:GetAABB(Entity.GlobalAABB), "ArrowWeapCheckPosition", self.entity) Callback: function ArrowWeapCheckPosition(entity, extra) if entity:GetCollisionType() == Collision.Trigger then if entity:GetAABB(Entity.GlobalAABB):IntersectsAABB(extra:GetAABB(Entity.GlobalAABB)) then System:Print("Yep") else System:Print("Nope") end extra.script.valid_position = false return end end Spawn code: local trap = Prefab:Load("Prefabs/Traps/arrow_trap.pfb") trap:SetParent(nil, true) trap:SetPosition(pickinfo.position, true) trap:AlignToVector(pickinfo.normal) trap:UpdateAABB(Entity.LocalAABB + Entity.GlobalAABB + Entity.RecursiveAABB) trap:Show() 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.