I want to set some objects inactive when my scene starts and I want to enable them consequently after some time (basically it’s a title and I want each letter to appear a few milliseconds after the previous one).
I’ve made each letter a separate GameObject, since I want to rotate them too. I suppose there is the “wrong” way of attaching a single script to each letter individually and setting a timer to each script.
I thought of doing it more “correctly”, by adding BoxCollider2D components to each letter and having an empty GameObject with a BoxCollider2D moving through my screen, enabling each letter one at a time.
My Start method is
void Start () {
GameObject[] titleElements = GameObject.FindGameObjectsWithTag ("Title");
foreach (GameObject titleElement in titleElements)
titleElement.SetActive(false);
}
and it works fine, since I’ve tagged each of my letters as “Title”, when I start my scene all these objects get deactivated.
In the Update method I move my empty “trigger” object horizontally in my scene, all of my objects have collider2D components with “isTrigger” enabled and my trigger object also has a RigidBody2D component. I had followed some tutorial on how to make a 2D game (clonybird if anyone is familiar) and it turns that I have to set my RigidBody2D Gravity to 0 and disable isKinematic or else my trigger object won’t collide with the other colliders.
But my letters don’t seem to collide with my trigger. Maybe this has to do with the fact that they are children to a camera which is a part of an NGUI-based GUI and I’m not 100% familiar with the way this works yet, I use it to have a resolution-independent UI.
I created an empty Game object with a BoxCollider2D object to test my logic and now my trigger triggers both this empty GameObject and a single Gameobject of my title, which is not the first it collides to. I really cannot understand what is happening.
I know it’s a very long post, but if anyone makes anything out of it I would be grateful…