hey guys, im trying to have a tank shooting, so a have a tank which has a turret, the end of a turret has an empty object from where i the shell spawns and im using this script:
public var shellSpawn : Transform;
public var shell : Transform;
function Start () {
}
function Update () {
if(Input.GetKeyUp("mouse 0"))
{
var object = Instantiate(shell, shellSpawn.transform, shellSpawn.rotation);
object.
}
}
but the problem is that for some reason the shell dosnt allway spawn where its supposed to spawn
here is the code how i rotate my gun:
public var gunPrefab:Transform;
private var gun:Transform;
function Start () {
gun = Instantiate(gunPrefab,transform.position,transform.rotation);
gun.parent = transform;
}
function Update () {
var temp : Vector3;
temp.x = Input.GetAxis("Mouse Y") * (-1);
temp.y = Input.GetAxis("Mouse X") ;
temp.z = transform.rotation.z;
if((temp.x > 0 && gun.localRotation.x > 0.10) || (temp.x < 0 && gun.localRotation.x < (-0.10)))
{
temp.x = 0;
}
if((temp.y > 0 && gun.localRotation.y > 0.15) || (temp.y < 0 && gun.localRotation.y < (-0.15)))
{
temp.y = 0;
}
gun.transform.Rotate(temp);
}