YouGroove Posted March 2, 2015 Share Posted March 2, 2015 I have a Pick function that is pretty simple It just detects if some entity with teamid = 2 is found using Pick() function Script:Raycast() self.entity:SetPickMode(1) local p0p = self.p0:GetPosition() local p1p = self.p1:GetPosition() local world = World:GetCurrent() local pi = PickInfo() if (world:Pick(p0p , p1p , pi, 0, true)) == false then return 0 end if pi.entity ~= nil and pi.entity.script ~= nil and pi.entity.script.teamid == 2 then return 1 end return 0 end When i call that function for the player , firing anywhere, two mobs droids start to moving to the player and don't stop turning around. function Script:Fire() self.upperAnimMgr:SetAnimationSequence("fire", 0.01, 75, 1) self.entity:Hide() local timediff = Time:GetCurrent() - self.timer if timediff > self.timerRate then self.timer = Time:GetCurrent() local entityPick = self:Raycast() end self.entity:Show() end Is Pick triggering events or something on other entities scripts ? I thaught Pick() was a simple raycast detection with no impact on collisions or gameplay ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
nick.ace Posted March 3, 2015 Share Posted March 3, 2015 It doesn't have any effect. Maybe you aren't being careful with variables? It's hard to tell with the code you provided. Can you post a snippet of the AI code? 1 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2015 Author Share Posted March 3, 2015 There is no reason at all. Player raycast function Script:Raycast() self.entity:SetPickMode(1) local p0p = self.p0:GetPosition(true) local p1p = self.p1:GetPosition(true) local world = World:GetCurrent() local pi = PickInfo() if (world:Pick(p0p , p1p , pi, 0, true)) == false then return 0 end if pi.entity ~= nil and pi.entity.script ~= nil and pi.entity.script.teamid == 2 then entityPick.script:decreaseHealth(self.damage) self.debugSphere3:SetPosition( pi.entity:GetPosition(true),true) return 1 end return 0 end Droid called function : function Script:decreaseHealth(amount) self.health = self.health - amount if self.health < 0 then --self.health = 0 self.entity:Release() end end the problem is calling that and the droid runs to the player and around him ? Even if i comment the player line code : entityPick.script:decreaseHealth(self.damage) I will post a zip example with scripts. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2015 Author Share Posted March 3, 2015 I made a minimal example and the problem is still here ? How to test : - put map fil in your map directory - put folder "ScriptsTPS" in your root directory of your project. - run the game , left click to fire The mob will start moving and turning around the player when you fire, and it should not move as there is no code on Pick changing any variables of the mob ?? I found that facing the mob it detects you so it stops moving, but if you only rotate yourself and don't face it , it no more detects you ? Maps.zip Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2015 Author Share Posted March 3, 2015 why the player raycast make the mob movig ? as anything in the function calls the mob script function or variables ? function Script:Raycast() self.entity:SetPickMode(0,true) local p0p = self.p0:GetPosition(true) local p1p = self.p1:GetPosition(true) local world = World:GetCurrent() local pico = PickInfo() local hit = world:Pick(p0p , p1p , pico, 0, true) if hit == true then --self.debugSphere3:SetPosition( pico.position,true) end self.entity:SetPickMode(1) if pico.entity ~= nil and pico.entity.script ~= nil then --and pi.entity.script ~= nil and pi.entity.script.teamid == 2 --entityPick.script:decreaseHealth(self.damage) --self.debugSphere3:SetPosition( pi.entity:GetPosition(true),true) --self.debugSphere3:SetPosition( pi.position,true) self.debugSphere3:SetPosition( pico.position,true) end return 0 end I think it is a serious bug. Anyone is hot to try the demo ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
nick.ace Posted March 3, 2015 Share Posted March 3, 2015 I can try it tonight when I get time to work on my computer. One problem I see right now in the AI code is that self.target never gets assigned anything, but idk if that does anything. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2015 Author Share Posted March 3, 2015 No the target loosed, it's a LE3 bug about scripts. In the game on my map the droid have "player" enitty assigned in the script tab. What is crazy , is just launching a Player Pick() have an impact oin the droid Pick(), because the droid uses Pick() every time. Ok, i just found the problem , when i have this line of code the droid don't find the player no more with raycast : self.entity:SetPickMode(1) If i remove that line, it works. I changed the code to function Script:Raycast() self.entity:SetPickMode(0) local p0p = self.p0:GetPosition(true) local p1p = self.p1:GetPosition(true) local world = World:GetCurrent() local pi = PickInfo() local picked = world:Pick(p0p , p1p , pi, 0, true) self.entity:SetPickMode(1) if picked == false then return 0 end if picked == true then if pi.entity ~= nil and pi.entity.script ~= nil and pi.entity.script.teamid == 2 then --entityPick.script:decreaseHealth(self.damage) self.debugSphere3:SetPosition( pi.entity:GetPosition(true),true) return 1 end end return 0 end But using : self.entity:SetPickMode(1) And the dorid cannot detect the player again. Why Monster AI do two call in Start() function ? self.entity:SetPickMode(Entity.BoxPick,true) self.entity:SetPickMode(0,false) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
nick.ace Posted March 4, 2015 Share Posted March 4, 2015 I'm not sure I follow what's going on here, but I guess it works now? Also, I'm really sorry, but I some things came up and I'm very busy so I can't test it tonight. Why Monster AI do two call in Start() function ? self.entity:SetPickMode(Entity.BoxPick,true) self.entity:SetPickMode(0,false) I think what this is doing is specifying the pick type for the hitboxes (children) and the actual mesh (parent), and then removes the parent from future pick tests to increase performance. I just think it's easier to do it in two lines than to iterate through all of the children. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 4, 2015 Author Share Posted March 4, 2015 I think what this is doing is specifying the pick type for the hitboxes (children) and the actual mesh (parent), and then removes the parent from future pick tests to increase performance. I just think it's easier to do it in two lines than to iterate through all of the children. I understand better now, thanks, sometimes when there is no comment it's hard to guess what coders are doing Quote Stop toying and make games 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.