- Home /
This question was
closed Aug 14, 2014 at 04:47 PM by
Lukamyte for the following reason:
Alternative option to guns (swords, a hack 'n' slash favorite!)
Question by
Lukamyte · Aug 14, 2014 at 03:07 PM ·
rotationinstantiatebullet
Instantiate rotation not working
Hi. My game has a part of a script i am using to instantiate bullets, but the rotation argument on the Instantiate is not working like I want it to.
var y : float;
function Update () {
y = transform.eulerAngles.y;
if(clicked){
Instantiate(bullet, transform.position,Quaternion.EulerAngles(0, y, 0));
}
}
The bullet ends up shooting off into some random direction, anything but what I want. Thank you!
Comment
Answer by MrSteve1 · Aug 14, 2014 at 03:11 PM
exchange Quaternion.EulerAngles(0,y,0) for transform.rotation.
Hope this helps.
I would perhaps reccommend spawning from an empty game object as an independent spawn point, then you wont have to rely on rotations. Try this`enter code here`
var spawnPoint : Transform;
function Update()
{
if(clicked)
{
Instantiate(bullet,spawnPoint.position,spawnPoint.rotation)
}
}
Hope this helps more.
Dont forget to child the spawnpoint close to the end of the barrel or cannon (whatever your using) but not touching it.