- Home /
Instantiated Object - Look At.
I'm in quite of a block right now.
I just finished the Dash move: Player presses Shift with directional key and the character makes a quick move in that direction.
As the coding is done, it's time for the graphic part. I prepared the "Dash Lines" - a simple, animated, transparent lines indicating movement.
Now, I prepared a Prefab of a quad with these lines texture, which has to be instantiated on Player's position AND turned to face his movement direction.
First thought: transform.LookAt, nothing simplier. BUT apparently, I cannot assign a Transform to an instantiated Prefab's variable via Inspector. I also cannot use GameObject.Find.Transform, because it's too slow - for a bare 0.1 second I can see how the lines are "teleporting" from the default to the correct angle after being instantiated.
Any way to make it work?
There's also not much code to show - just simple Instantiate for now.
Why Instantiate? Why not just show and hide the object? And if you are Instantiating, you could leave the renderer off until the lines are in the correct position.
Answer by Vel_1828 · Jul 16, 2014 at 09:57 PM
@ robertbu: "if you are Instantiating, you could leave the renderer off until the lines are in the correct position."
Well, that was clever, I'd never think of it that way. But as I see now - it really works. Good thinking, thank you again! :P
Your answer
![](https://koobas.hobune.stream/wayback/20220613154243im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotating a GameObject 180 to face another Gameobject on single axis 0 Answers
Rotate to Center of Screen 2 Answers
How to rotate an object depending on the rotation of an other Object 3 Answers
Why does transform.Rotate not move the sprite and BoxCollider2D together? 1 Answer
Move & Rotate Camera after OnMouseDown() 2 Answers