Jump to content

world pick collision type doesn't work


AggrorJorn
 Share

Recommended Posts

Either I am doing something wrong or it isn't working as intended. The last parameter from the world.Pick() is used to check for a specific collision type. However for me this pick only reacts to props. Whether I use Collision.Character or set a custom value for my object.

 

If I would set the collision type to character for instance and place a barrel in the raycast, then the pick is saying it is succesful while the barrel is of type prop.

 

local pickInfo = PickInfo()
local p0 = self.entity:GetPosition()
local p1 = Transform:Point(0, 0, 5, self.entity, nil)
if self.entity.world:Pick(p0,p1, pickInfo, 0, true, 25) then --the 25 is a custom collision type
  System:Print("pick success")
end

Link to comment
Share on other sites

If memory serves from LE2, the collisiontype you set for a pick is just like setting the collisiontype for an entity. So setting the Pick's collisiontype to character should return true (successful) since the default collision response is for characters to collide with props.

 

See the collision response table for reference: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/collision-r778

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

If I would set the collision type to character for instance and place a barrel in the raycast, then the pick is saying it is succesful while the barrel is of type prop.

When set to character (or even leaving that parameter empty) the pick is unsuccessful.

 

I'm confused... which one is it?

 

If the pick is set to character then it should be successful when hitting an entity with a prop collisiontype based on the collision response table. When the pick's collisiontype is not set then it will collide with any pickable entity.

 

Example script that shows what I am talking about:

function App:Start()
       self.window = Window:Create()
       self.context = Context:Create(self.window)
       self.world = World:Create() 
       self.camera = Camera:Create() 
       self.camera:Move(0,0,-4) 
       self.light = DirectionalLight:Create() 
       self.light:SetRotation(35,35,0) 

       self.model1 = Model:Box() 
       self.model1:SetPosition(-2,0,0) 
       self.model1:SetPickMode(Collision.None)

       self.model2 = Model:Box() 
       self.model2:SetPosition(2,0,0) 
       self.model2:SetCollisionType(Collision.Prop)

       self.toggle = 1 

       return true
end

function App:Loop()
       if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

       if self.model1:GetPosition().y > 2 then
                 self.toggle = -1
       elseif self.model1:GetPosition().y < -2 then
                 self.toggle = 1
       end
       self.model1:Translate(0,0.03*Time:GetSpeed()*self.toggle,0)

       local pickinfo = PickInfo() 
       local p0 = self.model1:GetPosition()
       d0 = self.camera:Project(p0)
       local p1 = Transform:Point(6, 0, 0, self.model1, nil)
       local pick = self.world:Pick(p0,p1,pickinfo,0,true,Collision.Character)
       if pick then
                  d1 = self.camera:Project(pickinfo.position)
       else
                  d1 = self.camera:Project(p1)
       end

       Time:Update() 
       self.world:Update() 
       self.world:Render() 
       self.context:SetBlendMode(Blend.Alpha)
       self.context:SetColor(1,0,0,1)
       self.context:DrawText("Pick: "..string.format("%s", pick),0,20)
       self.context:DrawLine(d0.x,d0.y,d1.x,d1.y)
       self.context:SetColor(1,1,1,1)
       self.context:SetBlendMode(Blend.Solid)
       self.context:Sync() 

       return true
end

 

Change the pick's collisiontype to 'Collision.LineOfSight' and you will see that it doesn't return successful - just like it should according to the collision response table. If you remove the pick collisiontype parameter, it will return successful with any pickable entity.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Are you by chance colliding with the entity that you are using as the initial point for the pick? Either you have to move the starting point of the raycast away from the entity or you have to set the entity's pickmode to 0.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I am using a pivot as a starting point for the pick. So no model is interfering there.

 

I have placed an oilbarrel in the picks raycast for testing.

If I use:

if self.entity.world:Pick(p0,p1, pickInfo, 0, true, Collision.Prop) then

Then it will return true since it is hitting a oilbarrel.

 

If I use:

if self.entity.world:Pick(p0,p1, pickInfo, 0, true, Collision.Character) then

Then it will also return true since it is hitting a oilbarrel.

 

However, if I move the oilbarrel out of the way and I use either 2 lines, the player does not get detected. Maybe the player controller can't get detected that way.

Link to comment
Share on other sites

If the oil barrel has a prop collisiontype, and you set the raycast's collsiontype to prop or character then the pick will be always be true. In LE2 there was an issue with animated characters blocking the character controller from raycasts which is why you had to use hitboxes. I believe Josh made a video for the LE3.0 prototype at one point showing the same thing.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Yips that's the problem. The raycast doesn't work on the character controller. Using a hitbox with as test type debris works.

I thought I was misunderstanding the way the collision parameter worked, but luckely that was okay.

 

Thanks for the help guys. Making a hitbox hadn't crossed my mind.

Link to comment
Share on other sites

  • 3 weeks later...

The FPS player script sets its own pick mode to 0 so that bullets go through it and intersect the hitboxes, instead of the silly stand-in mesh.

 

Is this actually a bug, or was that the explaination?

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

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...