-NullReferenceException: Object reference not set to an instance of an object
-Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
-Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
-Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
-UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
-ShootScript+$FireOneShot$3+$.MoveNext () (at Assets/Scripte/ShootScript.js:41)
-UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
-ShootScript:fire() (at Assets/Scripte/ShootScript.js:19)
-ShootScript:Update() (at Assets/Scripte/ShootScript.js:12)
j'ai recopier le script a la lettre près mais quand je tire le jeu se tire , Voici mon script :
Code : Tout sélectionner
var fireRate=0.30;
var impact:GameObject;
var canFire=true;
var damage:float=4;
var shootSound:AudioClip;
Screen.showCursor=false;
function Update(){
if(Input.GetButton("Fire1")){
fire();
}
}
function fire(){;
if(canFire==true){
canFire=false;
FireOneShot();
}
}
function FireOneShot(){
audio.PlayOneShot(shootSound);
var Direction=transform.TransformDirection(Vector3.forward);
var hit:RaycastHit;
if(Physics.Raycast(transform.position,Direction,hit,100)){
tempRot=Quaternion.FromToRotation(Vector3.up,hit.normal);
Instantiate(impact,hit.point,tempRot);
if(hit.rigidbody){
hit.rigidbody.AddForce(1000*Direction);
}
hit.collider.SendMessageUpwards("makedamage".damage.SendMessageOptions.DontRequireReceiver);
}
yield WaitForSeconds(fireRate);
canFire=true;
}
Code : Tout sélectionner
var hitPoints=20;
var explosion:Transform;
function makeDamage(damage:float){
hitPoints-=damage;
if(hitPoints<=0){
Instantiate(explosion.transform.position.transform.rotation);
Destroy(gameObject);
}
}