First of all, if you use JS and not C#, I know them both very well and can convert it, as I used JS for around a year before switching to C#.
Now, I know this is probably a really stupid question, but I need to convert RaycastHit.point to a local space ON an object. I don’t exactly know how to explain this, so I make a simple example picture.
Here’s the link, Unity Answers was being an ass and wouldn’t let me put the picture even though it was a smaller file
So, if anyone could please tell me how to have this returned as a Vector2, or Vector3 if needed, then thank you!
I imagine it’s something to do with its current position and its scale, but I’m unsure of exactly what to do, this is probably something very very easy.
Thanks in advance!
Well, to transform a world position into a local position you can simply use “InverseTransformPoint” of your target object. So the resulting point is relative to the target objects space. This is actually the reverse method of TransformPoint which transforms a localspace position into worldspace.
However, keep in mind that localspace might be something different then what you think. What you’ve drawn looks like texture / UV space. However if the origin of that plate is at that 0, 0 point it should work if the object has a unscaled size of “1”.