Search the Community
Showing results for tags 'foreachentityinaabbdo'.
-
If I make an aabb in front of the player's camera like this : if window:KeyHit(Key.Q) then --local model1 = Model:Box() --local model2 = Model:Box() local spellPointMin = Transform:Point(-2,-2,0.1, self.camera, nil) local spellPointMax= Transform:Point(2,2,5, self.camera, nil) --model1:SetPosition(spellPointMin) --model2:SetPosition(spellPointMax) local aabb = AABB(spellPointMin, spellPointMax) world:ForEachEntityInAABBDo(aabb,"Callback") end I believe it will work in the standard fpsplayer script, and it uses various functions like ForEachEntity which should call the global "Callback" function on an entity the callback function looks as follows (and works): function Callback(entity,extra) --this function needs to be global, for the aabb in the player script (Somewhere around ...Key.Q... line) if (entity:GetClass()==Object.ModelClass) then if(entity:GetKeyValue("type") == "movEntity") then entity:SetColor(1,0,0) end end end And to make a moveable Entity detect I set a key value as above to the entity. It works all fine, but only sometimes. When I walk toward an object with the KeyValue and constantly press q, nothing happens. However if I then move, and press q again, it works fine. If the angle is right (it sometimes will never work under certain angles no matter if its obfuscated or not) Here is a video : 2019-02-07 22-21-18.mp4 Thats it. I hope someone can help me solve this problem, and its not a bug.