- Home /
Setting an objects instantation rotation?
Hey, I am working on a gun script, the projectile is currently flying up and I want it to instantiate flying forward, by rotating it by 90 degrees x. I am using this script but Im not good enough with Quaternion Euler angles to modify the script in such a way, can anyone help me?
function FireOneBullet ()
{
var Bullet = Instantiate(Bullet, FirePoint.transform.position, transform.rotation);
Ammo --;
}
Answer by aldonaletto · May 19, 2013 at 10:51 PM
Use FirePoint.transform.rotation, and make sure the object FirePoint is pointing in the desired direction:
var Bullet = Instantiate(Bullet, FirePoint.transform.position, FirePoint.transform.rotation);
If the bullet is still going in the wrong direction, rotate FirePoint in the Editor to fix this.
Answer by sparkzbarca · May 19, 2013 at 10:47 PM
this is best fixed by going into a modelling program and rotating the object so the it's properly axis aligned (and therefore its forward is it's forward in unity on import)
YOU DO NOT WANT TO KEEP FIGHTING THIS EVERY TIME YOU WANT TO GET THE BULLETS FORWARD BACKWARD LEFT RIGHT UP AND DOWN.
Rotate in blender and re-import.
mark as answered please :)
Your answer
Follow this Question
Related Questions
Instantation Lag In Unity With Simple Game Object 1 Answer
Setting bullet instansiate direction? help? 1 Answer
Bullet Always fires down the Z Axis using Bullet Drop/Trajectory Formula? 1 Answer
Issues when instantiating moving object from other moving object 2 Answers
For some akward reason bullet is moving in the wrong direction 1 Answer