ERRO DE SCRIPTS
3 participantes
Página 1 de 1
ERRO DE SCRIPTS
[img][/img]
- Código:
using UnityEngine;
using System.Collections;
public abstract class WeaponBase : MonoBehaviour {
public BulletBehaviour bullet;
public Transform canoArma;
public Animation animationGun;
public AnimationClip reloadAnimation;
public AnimationClip fireAnimation;
public ParticleSystem fireParticle;
public AudioClip shotSound;
public AudioClip reloadSound;
public AnimationClip giveAnimation;
public AnimationClip getAnimation;
public int priceWeapon;
public int priceBullets;
public bool haveWeapon;
//Zoom
public AnimationClip zoomIn;
public AnimationClip zoomOut;
public float SensibityGun = 5;
public float zoomAim = 30;
private float startZoom;
private bool inZoom = false;
private float initSensibity;
public float timeToEnableZoom = 0;
private float currentTimeToEnableZoom = 0;
private bool callZoom;
///
//Fire
public float fireRate = 2;
private float currentTimeToFire = 0;
private bool canFire = true;
public int amountBullets = 16;
public int limitBullets;
public int munition = 64;
public float powerShot = 100;
public float range = 500;
private int initBullets;
public float timeToPlayReload = 0.5f;
private float currentTimeToPlayReload = 0;
public float recoil = 0.2f;
public MouseLook axiY;
public MouseLook axiX;
private float startRecoil;
public GUIText aimDisplay;
private GUIText tempAim;
public bool useByEnemy = false;
//
// Use this for initialization
protected void Start () {
initBullets = amountBullets;
if(!useByEnemy){
startZoom = Camera.main.fieldOfView;
initSensibity = axiX.sensitivityX;
startRecoil = recoil;
if(aimDisplay != null)
tempAim = Instantiate(aimDisplay) as GUIText;
}
}
// Update is called once per frame
protected void Update () {
if(canFire == false){
currentTimeToFire += Time.deltaTime;
if(currentTimeToFire > fireRate){
currentTimeToFire = 0;
canFire = true;
}
}
currentTimeToPlayReload += Time.deltaTime;
if(animationGun.isPlaying && animationGun.clip == reloadAnimation)
canFire = false;
if(callZoom){
currentTimeToEnableZoom += Time.deltaTime;
if(currentTimeToEnableZoom > timeToEnableZoom){
currentTimeToEnableZoom = 0;
AjustZoom();
callZoom = false;
}
}
}
public void Shoot(){
if(canFire == true && amountBullets > 0){
animationGun.clip = fireAnimation;
animationGun[animationGun.clip.name].time = 0;
animationGun.Play();
fireParticle.Emit(1);
canFire = false;
amountBullets--;
GetComponent<AudioSource>().clip = shotSound;
GetComponent<AudioSource>().Play();
bullet.powerShot = powerShot;
bullet.range = range;
bullet.isEnemyBullet = useByEnemy;
OnShoot();
currentTimeToPlayReload = 0;
if(!useByEnemy){
axiX.recoil = recoil;
axiY.recoil = recoil;
}
}
else if(amountBullets == 0){
ReloadWeapon();
}
}
abstract public void OnShoot();
public void ReloadWeapon(){
if(amountBullets < initBullets && currentTimeToPlayReload > timeToPlayReload){
if(munition > 0){
CancelZoom();
if(amountBullets <= initBullets){
int tempBullets = initBullets-amountBullets;
if(tempBullets >= munition)
tempBullets = munition;
amountBullets += tempBullets;
munition -= tempBullets;
}
animationGun.clip = reloadAnimation;
animationGun.Play();
GetComponent<AudioSource>().clip = reloadSound;
GetComponent<AudioSource>().Play();
}
}
}
public void Zoom(){
if(inZoom == false && !GetComponent<Animation>().isPlaying && !animationGun.isPlaying){
UseZoom();
}
else if(inZoom == true && !GetComponent<Animation>().isPlaying && !animationGun.isPlaying){
CancelZoom();
}
}
public void GiveWeapon(){
GetComponent<Animation>().clip = giveAnimation;
GetComponent<Animation>().Play();
}
public void GetWeapon(){
GetComponent<Animation>().clip = getAnimation;
GetComponent<Animation>().Play();
}
private void UseZoom(){
if(inZoom == false){
GetComponent<Animation>().clip = zoomIn;
GetComponent<Animation>().Play();
inZoom = true;
callZoom = true;
}
}
private void AjustZoom(){
for(int i=0; i<Camera.allCameras.Length; i++){
Camera.allCameras[i].fieldOfView = zoomAim;
}
recoil = startRecoil/2;
axiX.sensitivityX = SensibityGun;
axiY.sensitivityY = SensibityGun;
if(aimDisplay != null)
tempAim.enabled = false;
OnZoom();
}
public void CancelZoom(){
if(inZoom == true){
GetComponent<Animation>().clip = zoomOut;
GetComponent<Animation>().Play();
inZoom = false;
if(!useByEnemy){
for(int i=0; i<Camera.allCameras.Length; i++){
Camera.allCameras[i].fieldOfView = startZoom;
}
recoil = startRecoil;
axiX.sensitivityX = initSensibity;
axiY.sensitivityY = initSensibity;
if(aimDisplay != null)
tempAim.enabled = true;
}
OnCancelZoom();
}
}
abstract public void OnZoom();
abstract public void OnCancelZoom();
// void OnGUI() {
// if(!inZoom)
// GUI.Label(new Rect(Screen.width/2, Screen.height/2, 100, 20), "+");
// }
}
LeonradoGp- Membro
- PONTOS : 3612
REPUTAÇÃO : 3
Idade : 25
Respeito as regras :
Re: ERRO DE SCRIPTS
- Código:
using UnityEngine;
using System.Collections;
public class Arma : MonoBehaviour {
public Bala bala;
public AudioClip SomTiro;
public AudioClip recarregar;
public Transform CanoArma;
public Animation armasAnim;
public AnimationClip reload;
public AnimationClip FireAnim;
public AnimationClip Run;
public AnimationClip RunOut;
public ParticleSystem FireParticula;
public float fireRate = 2;
private float currentTimeToFire = 0;
///ZOOM!
public float zoomin;
private float startZoom;
private bool inZoom = false;
public AnimationClip zoomVai;
public AnimationClip zoomVolta;
private bool canFire = true;
public int quantidademuniçao = 7;
public int muniçao = 62;
private int initBullet;
// Use this for initialization
void Start () {
initBullet = quantidademuniçao;
startZoom = Camera.main.fieldOfView;
Cursor.visible = true;
}
// Update is called once per frame
void Update () {
if (canFire == false) {
currentTimeToFire += Time.deltaTime;
if(currentTimeToFire > fireRate){
currentTimeToFire = 0;
canFire = true;
}
}
if (Input.GetMouseButtonDown (0) && canFire == true && quantidademuniçao > 0){
Instantiate (bala, CanoArma.position, transform.rotation);
armasAnim.clip = FireAnim;
armasAnim.Play();
FireParticula.Emit(1);
canFire = false;
quantidademuniçao--;
GetComponent<AudioSource>().clip = SomTiro;
GetComponent<AudioSource>().Play();
}
if (Input.GetKeyDown(KeyCode.LeftShift)) {
armasAnim.clip = Run;
armasAnim.Play();
}
if (Input.GetKeyDown (KeyCode.K)) {
if(inZoom == false && !armasAnim.isPlaying){
UseZoom();
}
else if(inZoom == true && !armasAnim.isPlaying){
CancelZoom();
}
}
if (Input.GetKeyDown (KeyCode.R)&& quantidademuniçao < initBullet) {
if(muniçao > 0){
//muniçao --;
if(quantidademuniçao <= initBullet){
int tempBullets = initBullet-quantidademuniçao;
if(tempBullets>= muniçao)
tempBullets = muniçao;
quantidademuniçao += tempBullets;
muniçao -= tempBullets;
}
armasAnim.clip = reload;
armasAnim.Play();
GetComponent<AudioSource>().clip = recarregar;
GetComponent<AudioSource>().Play();
}
}
if(armasAnim.isPlaying == true){
canFire = false;
}
else{
canFire = true;
}
}
void OnGUI() {
GUI.Label (new Rect(Screen.width/2, Screen.height/2, 100, 20), "+");
}
private void UseZoom(){
if (inZoom == false) {
armasAnim.clip = zoomVai;
armasAnim.Play();
inZoom = true;
}
}
private void CancelZoom(){
if (inZoom == true) {
armasAnim.clip = zoomVolta;
armasAnim.Play();
inZoom = false;
}
}
}
LeonradoGp- Membro
- PONTOS : 3612
REPUTAÇÃO : 3
Idade : 25
Respeito as regras :
Re: ERRO DE SCRIPTS
- Código:
using UnityEngine;
using System.Collections;
public class Bala : MonoBehaviour {
public float speed = 10;
public float timeToLive =4;
private float currentTimeToLive= 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
currentTimeToLive += Time.deltaTime;
if (currentTimeToLive > timeToLive)
Destroy(gameObject);
transform.Translate (Vector3.forward * speed);
}
}
LeonradoGp- Membro
- PONTOS : 3612
REPUTAÇÃO : 3
Idade : 25
Respeito as regras :
Re: ERRO DE SCRIPTS
Esta ai os três scripts que estão dando erro, me ajudem se puder!
LeonradoGp- Membro
- PONTOS : 3612
REPUTAÇÃO : 3
Idade : 25
Respeito as regras :
Re: ERRO DE SCRIPTS
Você tem que colocar o nome certo neles... você apenas copiou e colou sem saber nem o que é...
O nome do script e o nome da classe devem ser os mesmos, e estão diferentes... por isto que está dando erro de global name
O nome do script e o nome da classe devem ser os mesmos, e estão diferentes... por isto que está dando erro de global name
Re: ERRO DE SCRIPTS
to com erro no meu jogo 2d tambem
using UnityEngine;
using System.Collections;
public abstract class Basemagic : MonoBehaviour {
//publics
public float speed;
public float timeToLive;
public float timeToRefresh;
public float damage;
//privates
private float currentTimeToRefresh;
// Use this for initialization
protected void Start () {
}
// Update is called once per frame
protected void Update () {
currentTimeToLive += Time.deltaTime;
if(currentTimeToLive > timeToLive)
Destroy(gameObject);
transform.Translate(Vector3.right * speed);
}
}
using UnityEngine;
using System.Collections;
public abstract class Basemagic : MonoBehaviour {
//publics
public float speed;
public float timeToLive;
public float timeToRefresh;
public float damage;
//privates
private float currentTimeToRefresh;
// Use this for initialization
protected void Start () {
}
// Update is called once per frame
protected void Update () {
currentTimeToLive += Time.deltaTime;
if(currentTimeToLive > timeToLive)
Destroy(gameObject);
transform.Translate(Vector3.right * speed);
}
}
jefersonguidio- Iniciante
- PONTOS : 3267
REPUTAÇÃO : 0
Respeito as regras :
Re: ERRO DE SCRIPTS
jeverson, crie um tópico específico para a sua dúvida, conforme as regras -.-
coloque lá o script e especifique exatamente o problema
coloque lá o script e especifique exatamente o problema
Tópicos semelhantes
» Alguem pode resolver o erro desses scripts, resolver o erro deste pacote
» Scripts com erro
» Erro ao adicionar scripts
» erro no scripts de dano no player 2D
» erro NO MONOBEHAVIOUR SCRIPTS IN THE FILE
» Scripts com erro
» Erro ao adicionar scripts
» erro no scripts de dano no player 2D
» erro NO MONOBEHAVIOUR SCRIPTS IN THE FILE
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos