22-08-2014, 03:37 PM
salve ragazzi,avrei bisogno di un aiuto per completare uno script,che ho preso da un Tutorial di un team di ragazzi che vuole finire un fps,che però non so se continueranno a farlo :/,comunque lo Script che ho preso da loro è questo:
using UnityEngine;
using System.Collections;
public class WeaponScript : MonoBehaviour {
public Set[] Weapons;
public Set currentweapons;
// Use this for initialization
void Start ()
{
currentweapon = Weapons[0];
CurrentWeapon.wepTrasform.animation.Play(currentWeapon.DrawAnim);
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
Currentweapon.wepTrasform.animation.Play(currentWeapon.fireAnim);
}
if(Input.GetKey(keyCode.R))
{
CurrentWeapon.wepTrasform.Animation.Play(currentWeapons.reloadAnim);
}
}
}
[System.Serializable]
public class Weapon
{
public string name;
public Transform wepTrasform;
public string fireAnim, drawAnim, reloadAnim;
}
ma quando vado a far partire il gioco su unity per vedere se funziona tutto sulla console mi escono 7 errori:
-Assets/weapons2.cs(22,26): error CS1502: The best overloaded method match for `UnityEngine.Input.GetKey(string)' has some invalid arguments
-Assets/weapons2.cs(22,33): error CS0103: The name `keyCode' does not exist in the current context
-Assets/weapons2.cs(20,25): error CS0103: The name `Currentweapon' does not exist in the current context
-Assets/weapons2.cs(13,17): error CS0103: The name `CurrentWeapon' does not exist in the current context
-Assets/weapons2.cs(12,17): error CS0103: The name `currentweapon' does not exist in the current context
-Assets/weapons2.cs(22,26): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
-Assets/weapons2.cs(24,25): error CS0103: The name `CurrentWeapon' does not exist in the current context
allora ho provato a modificarlo aggiungendo "public static Weapons",magari risolvevo qualcosa ed ecco il risultato:
2)
using UnityEngine;
using System.Collections;
public class WeaponScript : MonoBehaviour
{
public Weapons[] Weapons ;
public Weapons Currentweapons ;
public static Weapons
// Use this for initialization
void Start ()
{
Currentweapon = Weapons[0];
Currentweapon.wepTrasform.animation.Play(currentWeapon.DrawAnim);
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
Currentweapon.wepTrasform.animation.Play(currentWeapon.fireAnim);
}
if(Input.GetKey(keyCode.R))
{
Currentweapon.wepTrasform.Animation.Play(currentWeapons.reloadAnim);
}
}
}
[System.Serializable]
public class Weapon
{
public string name;
public Transform wepTrasform;
public string fireAnim,drawAnim,reloadAnim;
}
non funziona lo stesso,
però adesso mi da solo un errore:
-Assets/WeaponScript.cs(12,20): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration
ormai mi sono fermato 4 giorni su questo script e non so più cosa fare :/.spero che mi potrete aiutare
using UnityEngine;
using System.Collections;
public class WeaponScript : MonoBehaviour {
public Set[] Weapons;
public Set currentweapons;
// Use this for initialization
void Start ()
{
currentweapon = Weapons[0];
CurrentWeapon.wepTrasform.animation.Play(currentWeapon.DrawAnim);
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
Currentweapon.wepTrasform.animation.Play(currentWeapon.fireAnim);
}
if(Input.GetKey(keyCode.R))
{
CurrentWeapon.wepTrasform.Animation.Play(currentWeapons.reloadAnim);
}
}
}
[System.Serializable]
public class Weapon
{
public string name;
public Transform wepTrasform;
public string fireAnim, drawAnim, reloadAnim;
}
ma quando vado a far partire il gioco su unity per vedere se funziona tutto sulla console mi escono 7 errori:
-Assets/weapons2.cs(22,26): error CS1502: The best overloaded method match for `UnityEngine.Input.GetKey(string)' has some invalid arguments
-Assets/weapons2.cs(22,33): error CS0103: The name `keyCode' does not exist in the current context
-Assets/weapons2.cs(20,25): error CS0103: The name `Currentweapon' does not exist in the current context
-Assets/weapons2.cs(13,17): error CS0103: The name `CurrentWeapon' does not exist in the current context
-Assets/weapons2.cs(12,17): error CS0103: The name `currentweapon' does not exist in the current context
-Assets/weapons2.cs(22,26): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
-Assets/weapons2.cs(24,25): error CS0103: The name `CurrentWeapon' does not exist in the current context
allora ho provato a modificarlo aggiungendo "public static Weapons",magari risolvevo qualcosa ed ecco il risultato:
2)
using UnityEngine;
using System.Collections;
public class WeaponScript : MonoBehaviour
{
public Weapons[] Weapons ;
public Weapons Currentweapons ;
public static Weapons
// Use this for initialization
void Start ()
{
Currentweapon = Weapons[0];
Currentweapon.wepTrasform.animation.Play(currentWeapon.DrawAnim);
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
Currentweapon.wepTrasform.animation.Play(currentWeapon.fireAnim);
}
if(Input.GetKey(keyCode.R))
{
Currentweapon.wepTrasform.Animation.Play(currentWeapons.reloadAnim);
}
}
}
[System.Serializable]
public class Weapon
{
public string name;
public Transform wepTrasform;
public string fireAnim,drawAnim,reloadAnim;
}
non funziona lo stesso,
però adesso mi da solo un errore:
-Assets/WeaponScript.cs(12,20): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration
ormai mi sono fermato 4 giorni su questo script e non so più cosa fare :/.spero che mi potrete aiutare