Slastraf 79 Posted February 7 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. Share this post Link to post
Lethal Raptor Games 96 Posted February 7 Have you enabled debugging of all AABB's? I'm away from my pc atm but it somthing like camera->debugAABB(). Share this post Link to post
Slastraf 79 Posted February 8 11 hours ago, Lethal Raptor Games said: Have you enabled debugging of all AABB's? I'm away from my pc atm but it somthing like camera->debugAABB(). No I have not, but I don't use cpp because I wouldn't know how to set it up. Although if its really necessary I could. There is no documentation on debugAABB also ? Share this post Link to post
Josh 7,594 Posted February 8 I think it would be better to transform the center of the desired bounding box and then give it equal dimensions. The AABB will be aligned to global space, so it is getting squished at some angles, the way you have it now. Share this post Link to post
Slastraf 79 Posted February 8 5 hours ago, Josh said: I think it would be better to transform the center of the desired bounding box and then give it equal dimensions. The AABB will be aligned to global space, so it is getting squished at some angles, the way you have it now. Do you mean take only the middle point from the Transform:Point() function and then add / substract to make the vectors ? Or do you mean some function I dont know of yet. Share this post Link to post
Slastraf 79 Posted February 8 Okay so for everyone who has the same problem in the future, I fixed this by just transforming the origin point and then adding vectors to make each min and max, as josh said. -- activate currently selected spell --working code if window:KeyHit(Key.Q) then --local model1 = Model:Box() --local model2 = Model:Box() local p1 = Transform:Point(0,0,2.5, self.camera, nil) local pMin = p1 + Vec3(-2,-2,-2.4) local pMax = p1 + Vec3(2,2,2.5) --model1:SetPosition(spellPointMin) --model2:SetPosition(spellPointMax) local aabb = AABB(pMin, pMax) world:ForEachEntityInAABBDo(aabb,"Callback") end 1 1 1 Share this post Link to post