Question by
lukas0499 · Apr 06, 2017 at 04:48 AM ·
errorconsole errors
Problem with my script (Gun and Fire rate)
I have this script: #pragma strict
var projectile : Transform;
var shootForce : float = 20;
var fireRate : float = 0.1;
private var nextFire = 0.0;
function Update () {
// Put this in your update function
if(Input.GetKey("mouse 0")&&Time.time > nextFire){
nextFire = Time.time + fireRate;
// Instantiate the projectile at the position and rotation of this transform
var clone : Transform;
clone = Instantiate(projectile, transform.position, transform.rotation);
// Add force to the cloned object in the object's forward direction
clone.GetComponent.<Rigidbody>().AddForce(clone.transform.forward * shootForce);
}
}
and im receiving this errors from Unity:
Can somebody help me? Thanks!
05dddc51e9e45a8df16997c618308e65.png
(11.8 kB)
Comment
Best Answer
Answer by Chiroculon · Apr 06, 2017 at 12:30 PM
You seem to have gotten some HTML entities into your C# code.
Replace & with &
Replace > with >
Like so:
if(Input.GetKey("mouse 0") && Time.time > nextFire){