DooMAGE Posted July 17, 2017 Share Posted July 17, 2017 Hello, I'm trying to modify the FPSPlayer.lua to show hidden objects with the flashlight, but its not working. What I am doing wrong? function Script:UpdateWorld() local pickinfo=PickInfo() local p = self.flashlight:GetPosition() if (self.camera:Pick(p.x,p.y,pickinfo,0.5,true)) then pickinfo.entity:Show() end end Edit - I guess I should use world:pick instead? Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
gamecreator Posted July 17, 2017 Share Posted July 17, 2017 I didn't think pick worked on hidden objects. Are you sure it's supposed to? Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted July 17, 2017 Author Share Posted July 17, 2017 I think it works https://www.leadwerks.com/community/topic/2351-parented-hidden-objects-are-visible-for-raycasts/#comment-21510 Also I am trying to debug with: System:Print(pickinfo.entity.position) And it only shows "0.000000, 0.000000, 0.000000" no matter to where I look. So I think I am using pick wrong :/ Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
gamecreator Posted July 17, 2017 Share Posted July 17, 2017 In your case I'd check it with a visible entity and see if the pick returns true or false. If it returns true, just make the entity invisible and you'll know if it can pick it or not. 1 Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted July 17, 2017 Author Share Posted July 17, 2017 Yeah, looks like pick wont work with hidden objects (makes sense), and also earlier I was testing with a CSG object, and now I remember that CSG with no scripts is not an entity. /edit You can hide objects with pick Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
DooMAGE Posted July 19, 2017 Author Share Posted July 19, 2017 Update. It's working now, I use world:pick to raycast and test if the pickinfo I got is the object I want to show. Since the raycast wont work with hidden objects, I am changing its materials. Now the catch is, How can I detect if my raycast is not hitting the object I got before, so I can put the original material back? Tried this but my lastValidPickinfo thing is not working: if self.entity.world:Pick(p0,p1, pickinfo, 0, true) then if pickinfo ~= nil then if pickinfo.entity ~= nil and pickinfo.entity:GetKeyValue("name") ~= "" then self.lastValidPickinfo = pickinfo pickinfo.entity.script.showObject = true if self.lastValidPickinfo.entity:GetKeyValue("name") == "" then self.lastValidPickinfo.entity.script.showObject = false end end end Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 24, 2017 Share Posted July 24, 2017 Some pseudo code: if pickinfo ~= nil then if pickinfo.entity ~= nil and pickinfo.entity:GetKeyValue("name") ~= "" then --If there is a lastPickInfo, compare it to the current pickinfo name if(self.lastValidPickinfo ~= nil then if self.lastValidPickinfo.entity:GetKeyValue("name") ~= pickinfo.entity:GetKeyValue("name")) then --Now the pick is different than previous picked obj self.lastValidPickinfo.script.showObject = false end end self.lastValidPickinfo = pickinfo pickinfo.entity.script.showObject = true end end 1 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.