- Home /
find location on terrain when touch input
Hi,
I am making a Off road car game, you can see it here: [Rock Crawler][1] [1]: https://play.google.com/store/apps/details?id=kim.hoskin.rockcrawler
What I want to implement is a winch system, when touching somewhere on the rocks or terrain, how can I determine the x,y,z location of the touch? I guess the winch system could be easy to make, that could be a elongated cube and I just scale in one direction, moving the car along to the touch vector? But how to get the touch location on the rocks/terrain? With ray casting perhaps?
Thanks for any ideas/input.
Ok cool, so from that I get the objects name and it's location? then use that location in my winch code..
Any version of Physics.Raycast() that takes a RaycastHit as a parameter will allow you to get access to any of the GameObject properties like position, name, and tag. With the added use of GetComponent(), you can also get access to any public variables and functions in any script attached to that object. Raycast is the standard Unity way to solve your problem. Note that Raycasting requires that the objects have colliders.
Your answer
Follow this Question
Related Questions
Pinching invokes SingleTouch 1 Answer
Get new Point from Vector and Angle 1 Answer
Movement along with touch of finger 2 Answers
Problem getting touch input 0 Answers
How to get TouchPosition ?? 1 Answer