Error on Script Help Please.

Look my errors and all Script here. Can u help me please?

Assets/Script/Gun.js(38,94): BCE0127: A ref or out argument must be an lvalue: ‘(self.weight / 20)’

Assets/Script/Gun.js(38,53): BCE0017: The best overload for the method ‘UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ is not compatible with the argument list ‘(float, float, float, int)’.

Assets/Script/Gun.js(39,94): BCE0127: A ref or out argument must be an lvalue: ‘(self.weight / 20)’

Assets/Script/Gun.js(39,53): BCE0017: The best overload for the method ‘UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ is not compatible with the argument list ‘(float, float, float, int)’.

Assets/Script/Gun.js(40,94): BCE0127: A ref or out argument must be an lvalue: ‘(self.weight / 20)’

Assets/Script/Gun.js(40,53): BCE0017: The best overload for the method ‘UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ is not compatible with the argument list ‘(float, float, float, int)’.

Guns.js

public enum GunType{ Automatic, SemiAutomatic, ShotGun, BurstFire }

var Sparks	: Transform;
var muzzleFlash : Transform;

var NumberOfShots : int;
var damage	: float;
var FireRate	: float;
var spread	: float;
var recoil	: float;
var weight	: float;
var type	: GunType;
var magSize	: int;
var ammo	: int;

private var mag : int;
private var nextFire = 0.0;
private var SparksArray : Transform[];
private var ShotsLeft : int;
private var nextShot = 0.0;
private var ZAdd = 0.0;

private var DampX = 3.0;
private var DampY = 3.0;
private var DampZ = 3.0;

private var LockPosition : Vector3;

function Start(){
	SparksArray = new Transform[NumberOfShots];
	for(var i=0;i<SparksArray.Length;i++){
		SparksArray *= Instantiate(Sparks, Sparks.position, Sparks.rotation);*
  • }*
  • LockPosition = transform.localPosition;*
    }

function Update () {

  • transform.localPosition.x = Mathf.SmoothDamp(transform.localPosition.x, DampX, weight/20,5);*

  • transform.localPosition.y = Mathf.SmoothDamp(transform.localPosition.y, DampY, weight/20,5);*

  • transform.localPosition.z = Mathf.SmoothDamp(transform.localPosition.z, DampZ, weight/20,5) - ZAdd;*

  • switch(type){*

  •  case GunType.Automatic :*
    
  •  	if(Input.GetButton("Fire1")){*
    
  •  		if(Time.time > nextFire){*
    
  •  			nextFire = Time.time + FireRate;*
    
  •  			FireA();*
    
  •  		}else*
    
  •  			ZAdd = 0.0;*
    
  •  	}else{*
    
  •  		muzzleFlash.particleSystem.Stop();*
    
  •  		Sparks.particleSystem.Stop();*
    
  •  	}*
    
  •  break;*
    
  •  case GunType.SemiAutomatic :*
    
  •  	if(Input.GetButtonUp("Fire1")){*
    
  •  		if(Time.time > nextFire){*
    
  •  			nextFire = Time.time + FireRate;*
    
  •  			FireA();*
    
  •  		}else*
    
  •  			ZAdd = 0.0;*
    
  •  	}else{*
    
  •  		muzzleFlash.particleSystem.Stop();*
    
  •  		Sparks.particleSystem.Stop();*
    
  •  	}*
    
  •  break;*
    
  •  case GunType.ShotGun :*
    
  •  	if(Input.GetButton("Fire1")){*
    
  •  		if(Time.time > nextFire){*
    
  •  			nextFire = Time.time + FireRate;*
    
  •  			FireS();*
    
  •  		}else*
    
  •  			ZAdd = 0.0;*
    
  •  	}else{*
    
  •  		muzzleFlash.particleSystem.Stop();*
    
  •  		for(var i=0;i<SparksArray.Length;i++){*
    

_ SparksArray*.particleSystem.Stop();_
_
}_
_
}_
_
break;_
_
case GunType.BurstFire :_
_
FireB();_
_
if(Input.GetButtonUp(“Fire1”)&&Time.time > nextFire && ShotsLeft <= 0){_
_ nextFire = Time.time + FireRateNumberOfShots;_

* ShotsLeft = NumberOfShots; *
* }else{*
* muzzleFlash.particleSystem.Stop();*
* Sparks.particleSystem.Stop();*
* }*
* break; *
* }*
}

function FireB(){
* if(ShotsLeft > 0){*
* if(Time.time > nextShot){*
* nextShot = Time.time + FireRate; *
* FireA();*
* ShotsLeft–;*
* }else{*
* ZAdd = 0.0;*
* }*
* }*
}

function FireS(){
* for(var i=0;i<SparksArray.Length;i++){*
* var hit : RaycastHit;*
_ var BulletDirection = transform.TransformDirection(new Vector3(Random.Range(-spread, spread) * 0.002, Random.Range(-spread, spread) * 0.001,1));_

* if(Physics.Raycast(transform.position, BulletDirection, hit, Mathf.Infinity)){*
* if(hit.transform.gameObject.tag==“Player”)*
* hit.transform.SendMessage(“M_Damage”, damage);
_ SparksArray.position = hit.point;
Sparks.particleSystem.Play();
}
}
muzzleFlash.particleSystem.Play();
ZAdd = recoil;
mag–;
}*_

*function FireA() { *
* var hit : RaycastHit;*
_ var BulletDirection = transform.TransformDirection(new Vector3(Random.Range(-spread, spread) * 0.002, Random.Range(-spread, spread) * 0.001,1));_

* muzzleFlash.particleSystem.Play();*

* if(Physics.Raycast(transform.position, BulletDirection, hit, Mathf.Infinity)){*
* if(hit.transform.gameObject.tag==“Player”)*
* hit.transform.SendMessage(“H_Damage”, damage);
_ Sparks.position = hit.point;
Sparks.particleSystem.Play();
}
ZAdd = recoil;
mag–;
}*_

Hmm. The problem is obviously the first three lines in the Update() function. The compiler doesn’t like the values that you’re passing to Mathf.SmoothDamp(). Here’s a few things that you might need to do to fix it:

First, explicitly type the Damping variables as float:

private var DampX : float = 3.0;
private var DampY : float = 3.0;
private var DampZ : float = 3.0;

Second, try changing the 5 to a 5.0

transform.localPosition.x = Mathf.SmoothDamp(transform.localPosition.x, DampX, weight/20, 5.0);
    transform.localPosition.y = Mathf.SmoothDamp(transform.localPosition.y, DampY, weight/20, 5.0);
    transform.localPosition.z = Mathf.SmoothDamp(transform.localPosition.z, DampZ, weight/20, 5.0) - ZAdd;

lvalue is a legal value, that can be sent to a function, i.e. 0-1 for slerp type things, and 2048 values for audio fcts.