using UnityEngine;
using System.Collections;
public class StunGun : MonoBehaviour {
private Rigidbody curShot;
public Rigidbody shotPre;
public Transform shooter;
public float speed = 60.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
` if (Input.GetButton("Fire1")) {
Charge();
}
}
private void Charge () {
if (!curShot) {
curShot = (Rigidbody)Instantiate(shotPre, shooter.position, shooter.rotation);
}
curShot.transform.position = shooter.position;
curShot.transform.rotation = shooter.rotation;
if (Input.GetButtonUp("Fire1")) {
StartCoroutine(Shoot());
}
}
private IEnumerator Shoot () {
if (curShot) {
curShot.velocity = shooter.transform.TransformDirection(speed, 0, 0);
}
yield return new WaitForSeconds(2);
curShot = null;
}
}
in that code i get these errors, why?