Jump to content

Terrain and world:pick problem


Recommended Posts

I am trying to build a Top view shooting game

First I use Camera:Pick to get collided position by Mouse pointer to Terrain, everything ok, System:Print() can make output of collided position

--set shooting point follow mouse cursor
mousepos = window:GetMousePosition()
mousePickInfo = PickInfo()
if camera:Pick(mousepos.x,mousepos.y,mousePickInfo,0,true,Collision.LineOfSight) then
	shootingPoint:SetPosition(mousePickInfo.position)
  	--shootingPoint is a pivot which I created in Script:Start()
	System:Print(mousePickInfo.position)
end

Then I create a ray from player position to mousePickInfo.position then there is problem, the ray can not collide some areas of terrain and return 0,0,0 position, a height map was imported to construct terrain

bulletPickInfo = PickInfo()
world:Pick(
	body:GetPosition(true),
	mousePickInfo.position,
	bulletPickInfo,0.2,true,Collision.LineOfSight
)

I use a context:DrawLine to visualize the ray, and here the video, notice that when I move the mouse, sometime the red line changes its end point

 

Link to comment
Share on other sites

  • 8 months later...
  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...