Pastaspace Posted June 27, 2014 Share Posted June 27, 2014 What I am trying to work is out code that allows the player to use objects, in this case by pressing the E key when their mouse is over a usable object. Now this is done, the problem is the range. Using a pick, the camera will pick something regardless of its range to the player. So even if the button I use is fifteen miles away, it'll still activate it as long as the mouse is technically over it. My question is, Leadwerks 2.5 allowed us to give the pick a distance (anything past that distance was ignored basically), how do I do this in 3.2? tp_toPick.distance doesn't work. It always returns -1 regardless of distance. Basic code is here, with the action code cut out. if (window->KeyHit(Key::E)) { if (camera->Pick(centerMouse.x, centerMouse.y, tp_toPick, 0, true) == 1) { //If things are a certain distance, perform the relevant action on the pick. } } Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 Try to use a World Pick it gives you a starting Vec3 point and an ending Vec3 point for your pick. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/world/worldpick-r502 If you need the camera pick for whatever reason I think you could also calculate the distance between your pick point and your pick start manually. Something like -- if pickstart:GetPosition():DistanceToPoint(pickend:GetPosition()) < maxdistance then etc. pickstart, pickend and maxdistance are the changeable values. Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Pastaspace Posted June 27, 2014 Author Share Posted June 27, 2014 Tried that before, it gives me the distance between the entities, which does not always function correctly, for example, for a lot of larger objects. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 You may have tried this before but referring back to my example above what if you made pickend equal to the pickinfo.position? That should get rid of the distance between entities problem and should instead give you the distance between your entity and your pick position. Or tp_toPick.position in your case. It would look like if self.entity:GetPosition():DistanceToPoint(pickinfo.position) < maxdistance then etc. Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Pastaspace Posted June 27, 2014 Author Share Posted June 27, 2014 Have to tweak things around, but yep, that worked. Thanks. 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.