Ive been trying to develop a paintball game for some time now but whenever i try to make the guns Semi-Auto it doesn’t work
Here’s my code:
@HideInInspector
var targetXRotationV : float;
@HideInInspector
var targetYRotationV : float;
var rotationSpeed : float = 0.3;
var holdHeight : float = -0.5;
var holdSide : float = 0.5;
var racioHipHold : float = 1;
var hipToAimSpeed : float = 0.1;
@HideInInspector
var racioHipHoldV : float;
var aimRacio : float = 0.4;
var zoomAngle : float = 30;
var fireSpeed : float = 15;
@HideInInspector
var waitTillNextFire : float = 0;
var bullet : GameObject;
var bulletSpawn : GameObject;
function Update ()
{
if (Input.GetButton("Fire1"))
{
if (waitTillNextFire <= 0)
{
if (bullet)
Instantiate(bullet,bulletSpawn.transform.position, bulletSpawn.transform.rotation);
waitTillNextFire = 1;
}
}
waitTillNextFire -= Time.deltaTime * fireSpeed;
cameraObject.GetComponent(MouseLookScript).currentTargetCameraAngle = zoomAngle;
if (Input.GetButton("Fire2"))
{
cameraObject.GetComponent(MouseLookScript).currentAimRacio = aimRacio;
racioHipHold = Mathf.SmoothDamp(racioHipHold, 0, racioHipHoldV, hipToAimSpeed);
}
if (Input.GetButton("Fire2") == false)
{
cameraObject.GetComponent(MouseLookScript).currentAimRacio = 1;
racioHipHold = Mathf.SmoothDamp(racioHipHold, 1, racioHipHoldV, hipToAimSpeed);
}
transform.position = cameraObject.transform.position + (Quaternion.Euler(0,targetYRotation,0) * Vector3(holdSide * racioHipHold ,holdHeight * racioHipHold, 0));
targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(MouseLookScript).xRotation, targetXRotationV, rotationSpeed);
targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLookScript).yRotation, targetYRotationV, rotationSpeed);
transform.rotation = Quaternion.Euler( targetXRotation, targetYRotation, 0);
}
Please help me somebody ?