- Home /
Quit on Touch Script errors (Js)
}
function OnCollisionEnter (collision:Collision) {
if (collision(leader))
Application.Quit;
}
I'm trying to make a Quit on Contact script on Java Script where I select what the leader and follower is using a script that was already functional I get these errors:
Assets/Standard Assets/Scripts/CHASE.js(12,13): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Collision'.
Assets/Standard Assets/Scripts/CHASE.js(13,29): BCE0034: Expressions in statements must only be executed for their side-effects.
I would appreciate it if someone could tell me what I am doing wrong and hopfully how to play a sound and add a delay to the quit.
Answer by Imtiaj Ahmed · Jan 26, 2015 at 09:36 AM
First tag the leader object as "leader" without quote(" "), then use the following-
function OnCollisionEnter (collision:Collision) {
if(collision.gameObject.tag == "leader"){
audio.PlayOneShot (yourAudioClip);
Invoke ("QuitApplication", delayTime);
}
function QuitApplication(){
Application.Quit ();
}
Your collision(leader) approach is the problem i think.
Your answer
Follow this Question
Related Questions
OnCollisionStay for seconds then destroy 0 Answers
Destroy a GameObject 2 Answers
Overlap Detection HELP!! 0 Answers
What's wrong with my code? (Collision, JS) 2 Answers
Collsion without ririgibody 1 Answer