So i need help with my first game attempt.....

This is the mouselook script for the gun but it wont work properly with the else can someone help me understand why?

#pragma strict
var LookSens : float = 5;
var yRotation : float;
var xRotation : float;
var CurrentXRotation : float;
var CurrentYRotation : float;
var yRotationV : float;
var XRotationV : float;
var LookSmoothness : float = 0.1;
var bobSpeed : float = 1;
var stepCounter : float;
var bobAmountX : float =1;
var bobAmountY : float =1;
var lastPositon : Vector3;
var heightRatio : float;
var aimingTrue : float =1;
var cameraDefault : float = 60;
var targetCamera : float = 60;
var cameraZoom : float =1;
var cameraZoomV : float;
var cameraZoomSpeed : float = 0.1;

function Awake()
{
lastPositon = transform.parent.position;
}
function Update ()
{
if(aimingTrue == 1);
}
cameraZoom = Mathf.SmoothDamp(cameraZoom, 1, cameraZoomV, cameraZoomSpeed);
{

else

}

cameraZoom = Mathf.SmoothDamp(cameraZoom, 0, cameraZoomV, cameraZoomSpeed);
{
camera.fieldOfView = Mathf.Lerp(targetCamera, cameraDefault, cameraZoom);
if (Transform.parent.GetComponent(Movement).grounded)
{
stepCounter += Vector3.Distance(lastPositon, Transform.parent.position) * bobSpeed;
}
transform.localPosition.x = Mathf.Sin(stepCounter) * bobAmountX;
transform.localPosition.y = (Mathf.Sin(stepCounter * 2) * bobAmountY * -1) + (transform.parent.localScale.y * heightRatio) - (transform.parent.localScale.y/2);

lastPositon = transform.parent.position;

yRotation += Input.GetAxis(“Mouse X”) * LookSens;
xRotation -= Input.GetAxis(“Mouse Y”) * LookSens;

xRotation = Mathf.Clamp(xRotation, -80, 100);

CurrentXRotation = Mathf.SmoothDamp(CurrentXRotation, xRotation, XRotationV, LookSmoothness);
CurrentYRotation = Mathf.SmoothDamp(CurrentYRotation, yRotation, yRotationV, LookSmoothness);

transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);

Please use code tags when posting code.

1 Like

The “else” is written inside the braces (‘{’ and ‘}’), where it should be before them. Then, the stuff you want to happen when the test does not pass should go between the braces.