hi, i mademy new game, raycast and particle system shooting game
works great… like i need.
but always show this error…
pleasehelp
ArgumentException: GetComponentFastPath can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEngine.Component.GetComponent[ParticleEmitter] ()
raycastshooting…ctor () (at Assets/Raycast mau final unity5/Scripts/raycastshooting.js:7)
here is my code:
var EffectsObject: GameObject;
// var someParticleEmitter : GameObject;
var emitter = GetComponent.<ParticleEmitter>();
var TheDamage = 100;
function Update () {
var hit : RaycastHit ;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if (Input.GetMouseButtonDown(0))
{
GetComponent.<AudioSource>().Play();
emitter.emit = true;
if (Physics.Raycast (ray,hit,100))
{
print ("disparo");
var particleClone = Instantiate (EffectsObject, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(particleClone.gameObject, 3); // espera 5 segundosay destruye
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
// Debug.DrawLine (ray.origin, hit.point);
}
}
else
{
emitter.emit = false;
print ("-------");
}
}
