Jump to content

Pick() not working when not facing same direction


YouGroove
 Share

Recommended Posts

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.

pick3.jpg

 

 

 

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.

Stop toying and make games

Link to comment
Share on other sites

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 

 

pickout.jpg

Stop toying and make games

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...