Andy90 Posted September 30, 2023 Share Posted September 30, 2023 Hello the camera pick is working realy wired for me. You can see it within the video 2023-09-30 02-36-14 (streamable.com). This is my code function Script:Shot() --Create a sphere to indicate where the pick hits local pickradius = 0.1; picksphere = Model:Sphere() picksphere:SetColor(1.0, 0.0, 0.0) picksphere:SetPickMode(0) picksphere:SetScale(pickradius * 2.0) picksphere:Hide() picksphere:Hide() local pickinfo = PickInfo() local p = window:GetMousePosition() if (self.cam:Pick(p.x, p.y, pickinfo, pickradius, true, Collision.Prop)) then picksphere:Show(); picksphere:SetPosition(pickinfo.position); local name = pickinfo.entity:GetKeyValue("name"); pickinfo.entity:Hide(); System:Print(name); end end Quote Link to comment Share on other sites More sharing options...
Andy90 Posted October 3, 2023 Author Share Posted October 3, 2023 I got another problem with pick. It seems pick is ignoring animations. Without animation with the idle animation Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted October 4, 2023 Solution Share Posted October 4, 2023 Based on your video, I think the problem is that you are expecting it to pick the closest object. There is an optional value you should set to get this behavior. Otherwise, it just acts as a line-of-sight test and returns if any object is hit. Picking does not work on animated models because the vertices only move around on the GPU. In my AI scripts I handled this by using the box pick mode on all children of the model, then disabling picking on the model itself: self.entity:SetPickMode(Entity.BoxPick,true) self.entity:SetPickMode(0,false) This provides a close but efficient way to intersect an animated model with bullets and things. 1 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...
Andy90 Posted October 4, 2023 Author Share Posted October 4, 2023 5 hours ago, Josh said: Picking does not work on animated models because the vertices only move around on the GPU. In my AI scripts I handled this by using the box pick mode on all children of the model, then disabling picking on the model itself: Thank you, this is very helpful. I believe I've properly configured the parameters in my pick function to acquire the closest target. However, there's a chance I may have misunderstood something. self.cam:Pick(p.x, p.y, pickinfo, pickradius, true, Collision.Prop) ----- I also edited the model a bit because at some parts of the body was no hit registration. So i added some spheres and asign them an invisible hitbox material. Works great so far Quote Link to comment Share on other sites More sharing options...
Josh Posted October 4, 2023 Share Posted October 4, 2023 7 hours ago, Andy90 said: Thank you, this is very helpful. I believe I've properly configured the parameters in my pick function to acquire the closest target. However, there's a chance I may have misunderstood something. self.cam:Pick(p.x, p.y, pickinfo, pickradius, true, Collision.Prop) This looks correct to me. 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...
Andy90 Posted October 4, 2023 Author Share Posted October 4, 2023 I think it has something to do with the model. After I fixed the issue on the zombie model today, the hit registration on it is now perfect. It might be due to the surface size. Quote Link to comment Share on other sites More sharing options...
Alienhead Posted October 4, 2023 Share Posted October 4, 2023 Did you self-scale the model ? or scale via the editor's 'Resize' feature, it actually makes a huge difference. I found it way helpful to scale any animated mesh or boned objects outside of leadwerks and just bring it in at it's actual size, You cant resize then collapse a boned mesh in the editor without deleting it's hierarchy and that screws everything up.. Normal meshes you can resize in the editor then collapse when your done and it will retain a 1 to 1 scale which is what you want for picks and such. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Andy90 Posted October 4, 2023 Author Share Posted October 4, 2023 Im not sure anymore tbh. But i think it was the editor. Quote 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.