YouGroove Posted January 29, 2015 Share Posted January 29, 2015 HI, I have two points with debug spheres , i use a pick and an entity barell with a mass and empty script don't get detected by the ray. It is normal ? self.entity:SetPickMode(0) local pickinfo=PickInfo() local p0 = self.entity:GetPosition(true) p0.y = p0.y + 3 local p1 = p0 p1.y = p1.y - 3 if self.entity.world:Pick(p0,p1, pickinfo, 0,true) then self.debug="Raycast HIT COLLISION" end Any idea ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
gamecreator Posted January 29, 2015 Share Posted January 29, 2015 http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetpickmode-r135 The documentaion says SetPickMode(0) will skip the entity entirely. 1 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted January 30, 2015 Author Share Posted January 30, 2015 Yes, because the player entity is casting the raycast so i coded : self.entity:SetPickMode(0) This way the player that is casting the ray form it's center won't be taken in consideration for collision etection. I must have something wrong elsewhere ? , but the ray should detect BSP floor or walls ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Ma-Shell Posted January 30, 2015 Share Posted January 30, 2015 You are aware, that your ray goes into y-direction, which is upwards? I think you rather meant to edit z, not y (as anything with a mass won't stay above you for long ) Also these are global coordinates, so you would probably want to move the points along forward direction, not along a constant axis. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted January 30, 2015 Author Share Posted January 30, 2015 You are aware, that your ray goes into y-direction, which is upwards? Yep, floor detection Quote Stop toying and make games Link to comment Share on other sites More sharing options...
beo6 Posted January 30, 2015 Share Posted January 30, 2015 Floors i know are normally below me. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted January 30, 2015 Author Share Posted January 30, 2015 Yes, it is not what is doing the code ? The ray starts at p0 that is player center that is foots , i added 3 in Y to have it start just above hear of player model. And the ray ends at p1 that is p0 with y-3 , that is foots of the player. I had spheres debug to see the ray start and end position on 3D space and landing on a barrel entity it didn't detectd anything. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
diedir Posted January 30, 2015 Share Posted January 30, 2015 not sure but in LE 2.5 you need to hide entity before the raycast and show it after. it worked. Quote AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11 Link to comment Share on other sites More sharing options...
beo6 Posted January 31, 2015 Share Posted January 31, 2015 Can you try this? -- disable model picking self.entity:SetPickMode(0) local world = World:GetCurrent() local pickinfo = PickInfo() local pivotPos = self.entity:GetPosition() local rayStart = Vec3(pivotPos.x, pivotPos.y+1, pivotPos.z) local rayEnd = Vec3(rayStart.x, rayStart.y-50, rayStart.z) local pickSize = 0 if (world:Pick(rayStart,rayEnd,pickinfo,pickSize,true,Collision.Prop)) then local pickentity = pickinfo.entity end -- reenable model picking self.entity:SetPickMode(Entity.SpherePick) If that does not work try to set the pickSize higher. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 12, 2015 Author Share Posted February 12, 2015 I have no results and i don't understand if i use it well or not ? I have a sphere to visualize the ray end and it is okay, and i use pick like that : world:Pick(rayStart,rayEnd,pickinfo,pickSize,true) I put true so it returns the first intersection collision only, and no last parameter to return any kind of collision. function Script:RaycastPlayer() -- disable model picking self.entity:SetPickMode(0) local world = World:GetCurrent() local pickinfo = PickInfo() local pickSize = 0 local rayStart = self.entity:GetPosition(true) local pivot = self.entity:FindChild("ray") local rayEnd = pivot:GetPosition(true) self.debugSphere:SetPosition(rayEnd,true) if (world:Pick(rayStart,rayEnd,pickinfo,pickSize,true)) then local pickentity = pickinfo.entity if pickentity ~= nil and pickentity.id == 1 then return true end end -- reenable model picking self.entity:SetPickMode(Entity.SpherePick) return false end Quote Stop toying and make games Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 12, 2015 Share Posted February 12, 2015 These are 2d lines rather than 3d, but still useful to see the raycasts: p1 = camera:Project(point1) p2 = camera:Project(point2) self.context:DrawLine(p1.x, p1.y, p2.x, p2.y) See the raycasting tutorial for a complete lua script. http://www.leadwerks.com/werkspace/page/tutorials_legacy/_/introduction-to-raycasting-r13 1 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 12, 2015 Author Share Posted February 12, 2015 I would also like to debug on entities that are not associated with camera and that are using Raycast and a real 3D line is possible. Anyway i could debug better with your method, but the raycast passes through BSP , i would expect the ray to return the first collision, and when it's BSP that is first collision , the Pick should not find the player character then. I just need les theoric tutorials and more gameplay practical examples Quote Stop toying and make games Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 12, 2015 Share Posted February 12, 2015 The Camera:Project function converts 3d points to 2d. It doesn't have to be send from a camera to work, so drawing a line can be from any two point in space. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 12, 2015 Author Share Posted February 12, 2015 The main problem i have is the ray, it detects the player, but it detects the player throught BSP walls ? What means that in the doc of Pick() closest: if set to true, the closest intersection will be found, otherwise the operation will return as soon as a single intersection is found. It's not very clear. True means one collision only is returned, the first closest collision that happens False means all collisions will be returned Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 12, 2015 Author Share Posted February 12, 2015 I found a working solution : http://www.leadwerks.com/werkspace/topic/11840-animation-models-tutorial-request/page__hl__tutorial function Script:RaycastPlayer2() -- 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 Quote Stop toying and make games 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.