Slastraf Posted February 7, 2019 Share Posted February 7, 2019 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. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 7, 2019 Share Posted February 7, 2019 Have you enabled debugging of all AABB's? I'm away from my pc atm but it somthing like camera->debugAABB(). Quote Link to comment Share on other sites More sharing options...
Slastraf Posted February 8, 2019 Author Share Posted February 8, 2019 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 ? Quote Link to comment Share on other sites More sharing options...
Josh Posted February 8, 2019 Share Posted February 8, 2019 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. 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...
Slastraf Posted February 8, 2019 Author Share Posted February 8, 2019 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. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted February 8, 2019 Author Share Posted February 8, 2019 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 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.