- Home /
Addition Quaternion
I have a gun, this gun is basically a cylinder and with a sphere inside. The sphere is a child of the gun, so want ever rotation the gun is the sphere is. I have a script so when you press 'Z', it spawns the sphere in the direction of the gun is pointing. Now this rotation is very important to understand.
I want to add something into the script so the direction is slightly offset, you known to simulate caliber but I want to keep the general direction of the sphere. The gun is going to be moving and rotating so it is important to know that.
I was think something like '+ Random. Range(1,100)'? However you can't add integers to quaternions.
Here's the script:
#pragma strict
var ball : GameObject;
var rotation : Quaternion = transform.rotation;
function Start () {
}
function Update () {
if (Input.GetKeyDown(KeyCode.Z)){
Instantiate(ball,transform.position,transform.rotation);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612074816im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get real compass direction 1 Answer
Quaternion.Slerp not smooth! 0 Answers
How can I instantiate a gameobject facing another gameobject 2D? 0 Answers