AggrorJorn Posted July 26, 2014 Share Posted July 26, 2014 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2014 Share Posted July 26, 2014 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 Quote 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 More sharing options...
AggrorJorn Posted July 26, 2014 Author Share Posted July 26, 2014 That's the problem: When set to character (or even leaving that parameter empty) the pick is unsuccessful. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2014 Share Posted July 26, 2014 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. Quote 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 More sharing options...
macklebee Posted July 26, 2014 Share Posted July 26, 2014 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. Quote 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 More sharing options...
AggrorJorn Posted July 26, 2014 Author Share Posted July 26, 2014 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. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2014 Share Posted July 26, 2014 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. Quote 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 More sharing options...
gamecreator Posted July 26, 2014 Share Posted July 26, 2014 Crazy thought but sometimes this seems to come up: have you tried testing against a child instead? Can you check if your model has any children? But maybe I'm just thinking about tjheldna's status update. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 26, 2014 Author Share Posted July 26, 2014 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. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 26, 2014 Author Share Posted July 26, 2014 and the video you mentioned Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 if you are using the default fpsplayer script here then its causing your problem. It sets the player pickmode to 0. The better method would be to turn the pickmode off just prior to its picks then back on afterwards. Quote 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 More sharing options...
Josh Posted August 20, 2014 Share Posted August 20, 2014 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? Quote 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 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.