-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$1+$.MoveNext () (at Assets/Scripte/ShootScript.js:30)
-UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
-ShootScript:fire() (at Assets/Scripte/ShootScript.js:17)
-ShootScript:Update() (at Assets/Scripte/ShootScript.js:10)
Mon Scripte est le suivant :
Code : Tout sélectionner
var fireRate=0.30;
var impact:GameObject;
var canFire=true;
var shootSound:AudioClip;
Screen.showCursor=false;
function Update(){
if(Input.GetButton("Fire1")){
fire();
}
}
function fire(){
if(canFire==true){
canFire=false;
FireOneShot();
}
}
function FireOneShot(){
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);
}
yield WaitForSeconds(fireRate);
canFire=true;
}