- Home /
Question by
HuskyPanda213 · Dec 09, 2013 at 11:13 PM ·
vectorforward
Make a object instantaite 25 units in front
How do I make a object instantiate 25 units in front of my player. Can you explain how to add 25 units with vector3.forward.
Comment
Answer by Statement · Dec 09, 2013 at 11:19 PM
Just multiply 25 to your forward vector. In this case I guess you want to use the transform.forward rather than Vector3.forward (unless you want it to appear 25 units in front of it, in world coordinates).
var clone = (GameObject)Instantiate(prefab);
clone.transform.position = transform.position + transform.forward * 25;
Answer by zzeettoo · Dec 09, 2013 at 11:21 PM
along a certain axis? (the z-axis) or along the forward direction of the player? with z, you simply set the z-part of your instantiate position to 25, with the .forward of the player you take "the players .forward * 25" as the instantiate position
Your answer
![](https://koobas.hobune.stream/wayback/20220613123824im_/https://answers.unity.com/themes/thub/images/avi.jpg)