YouGroove Posted February 13, 2015 Posted February 13, 2015 Hi, I use pick(), it works, but only when the mob is facing the player. The problem is when using GotoPoint() the mob don't faces the player, and calling Pick() even with good spheres debug position , Pick don't work. I put a red and blue sphere to see pick start and pick end. function Script:RaycastPlayer2() self.debugSphere:SetPosition( self.target:GetPosition(true), true) self.debugSphere3:SetPosition( self.entity:GetPosition(true), true) -- disable model picking self.entity:SetPickMode(0) local world = World:GetCurrent() local pi = PickInfo() if (world:Pick(self.entity:GetPosition(true), self.target:GetPosition(true), pi, 0, true)) == false then return 0 end -- did we hit our target? if pi.entity == self.target then return 1 end -- we hit something else return 2 end The pick is called every frame at beginning of UpdateWorld. Why it don't works when the mob is facing another direction ? This is driving me nuts. Quote Stop toying and make games
YouGroove Posted February 14, 2015 Author Posted February 14, 2015 I put a new code having pick points higher than floor, but now it never returns player collision detection ? function Script:RaycastPlayer2() local posPlayer = self.target:GetPosition() local posMob = self.entity:GetPosition() posPlayer.y = posPlayer.y +1 posMob.y = posMob.y +1 self.debugSphere:SetPosition( posPlayer, true) self.debugSphere3:SetPosition( posMob, true) -- disable model picking self.entity:SetPickMode(0) self.debugSphere:SetPickMode(0) self.debugSphere3:SetPickMode(0) local world = World:GetCurrent() local pi = PickInfo() if (world:Pick(posPlayer, posMob, pi, 0, true)) == false then return 0 end -- did we hit our target? if pi.entity == self.target then return 1 end -- we hit something else return 2 end Quote Stop toying and make games
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.