- Home /
Instantiated object using parent's transform as world axes
I'm trying to have an object fire a projectile directly in front of it with this.
function FireLaser () {
var LaserClone : Rigidbody = Instantiate(laser,transform.position, transform.rotation);
}
The problem is that the instantiated object is using the transform rotation of the player object as its world axes, in effect doubling the intended rotation. If I use Quaternion.identity instead of transform.rotation it does fire along the world z-axis.
Answer by Tseng · Oct 16, 2011 at 11:25 PM
Then just use transform.localRotation
instead... a simple look up at the documentation should made it possible to yourself to find it out...
http://unity3d.com/support/documentation/ScriptReference/Transform.html
After some further investigation, I discovered that the rotation of the instantiated object was right, but the script controlling its movement was using local space. Setting that transform.Translate to world space fixed the problem.
Your answer
![](https://koobas.hobune.stream/wayback/20220613012035im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Instantiate projectile rotation 2 Answers
Fire Projectile based on Model rotation 1 Answer
Gun Projectile Shooting In Wrong Direction (Javascript) 1 Answer
Objects Instantiating at wrong position 3 Answers
Rotation troubles 2 Answers