I have a line renderer with three points. It has the property “Use world space” set to False, and I need to keep it that way for different reasons.
Sometimes, I need to change the position of the middle point (i.e point [1]). The new position is known in world space. This code is from a script in the line renderer’s object.
hah, someone else had the same problem and referred to it as magic!
Just FYI, a quick google would have found you the answer. Doing searches like this can help you get results faster… my advice would be to use these forums when you cant find/describe the problem properly.
Are you refering to the posted solution? I may be mistaken, or just don’t get it. But isn’t that the opposite of what I want to do? From what I can see, transform.TransformDirection is for transforming local space to world space. I can’t see how I can use it to go the other way?
And I’m sorry if this seems rather basic. I can surely see your point. But I just can’t get my head around it, and actually our friend google isn’t that clear about the matter either (I asked him before I asked you). But who knows, maybe it’s right in front of me and I just don’t see it.
At first I didn’t see the relation between the direction and the position. But by subtracting my “own” tranform.position from the position of the object I wanted to find out the localspace position from, and by using InverseTransformDirection on the difference, I got the right result. Still not completely 100% clear on why, but I guess it makes sense, since the difference would be the relative position (but without caring about rotation), and the InverseTransfromDirection takes care of the different rotations. Or something like that. It’s getting late I think.
Funny. Many many years later, I’m doing this exact same thing and completely forgot how. I toss a half sensible query at Google, and it gives me this response as “here’s a guy asking the exact same question for the exact same usage.” A very good reason to answer questions if you can, and not respond with a google it yourself.
The original poster provided the simple and proper answer himself, making MY query a perfect response.