- Home /
How do I stop an immediate collision with all objects from ocuring at the entry of game mode?
This is the simple script I'm running..
var GUI : GUITextExample; var Player : Transform;
function Start () {
GUI = GameObject.FindWithTag("GUI").GetComponent(GUITextExample);
}
function OnCollisionEnter(collision : Collision) {
if(collision.transform == Player); GUI.Counter += 1;
if(collision.transform == Player); Destroy(gameObject, 2); }
If I put out a bunch of objects, lets say 5 cubes with this script attached, as soon as I enter gamemode the counter will increase by 5 & 2 seconds later all of the cubes will be destroyed. If I turn off the destroy call then the counter still jumps to 5 but the script & counter work fine after that counting all of the player/cube collisions. Its like player throws out an immediate collision at start to everything and then the script & counter work fine? I tried moving this line..
GUI = GameObject.FindWithTag("GUI").GetComponent(GUITextExample); under the OnCollisionEnter function but that didn't make a difference.
I also tried this with no luck.
var GUI : GUITextExample; var Player : Transform;
function Start () {
}
function OnCollisionEnter(collision : Collision) {
if(collision.transform == Player); GUI = GameObject.FindWithTag("GUI").GetComponent(GUITextExample); GUI.Counter += 1; }
Your answer
Follow this Question
Related Questions
How to make a box (or any object) appear on collide? 1 Answer
how to call a gameobject in one function(mouse selection) to another function (GUI) 1 Answer
Script to parent player to object 1 Answer
Collider Error[SOLVED] 2 Answers
Nearest object code not falling back on alternate in OnGUI() 3 Answers