Добавлено (29.04.2014, 14:13)
---------------------------------------------
Sidiusz, тебе уже давали ответ..
но похоже ты как бревно тебе лишь все готовенькое...
ведь сказали - две фигурные скобы не хватает!
Код
using UnityEngine;
using System.Collections;
public class shoot : MonoBehaviour {
public int maxAmmo = 7;
public int curAmmo = 7;
private int poshet;
public int AmmoInBackPack = 100;
private bool reload = false;
public float timeOutShoot = 3;
public float shootTime = 0.4f;
public float TimeOutReload = 3;
public float ReloadTime = 0.5f;
public float ReloadStop = 1;
private RaycastHit Hit;
public Transform camera1;
void Update () {
timeOutShoot += Time.deltaTime;
timeOutReload += Time.deltaTime;
Vector3 lysh = camera1.TransformDirection(Vector3.forward);
if(Input.GetKeyDown(KeyCode.R) && curAmmo<maxAmmo && !reload && timeOutReload>ReloadTime) {
poshet = maxAmmo - curAmmo;
AmmoInBackPack = AmmoInBackPack - poshet;
reload = true;
}
if(reload) {
timeOutReload = 0;
curAmmo = maxAmmo;
reload = false;
}
if(Input.GetMouseButtonDown (0) && curAmmo>0 && timeOutShoot>shootTime && timeOutReload>ReloadStop) {
timeOutReload = 0;
curAmmo--;
if(Physics.Raycast(camera1.position, lysh, out Hit, 1000f)) {
Quaternion HitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
if(Hit.transform.rigidbody) {
Hit.Transform.Rigidbody.AddForceAtPosition(lysh*1000, Hit.point);
}
}
}
}
}