First of all, I would like to note that I really am a newbie at this, and I guess this question is trivial, but still, I need help with this.
So basically, I’ve been following [this][1] tutorial and finished it successfully. I wanted to add some more levels to it, and I created another planes adjacent to the first one. Now what I want to do is separate these planes with walls (success) and then, after all pickups are collected in “map” then make first wall disappear and after other collectibles are collected the second wall, and so on and so on.
I’m not that new to C#, but still get it quite confusing. I tried editing the PlayerController script (where the collectibles are counted and the message after collecting them all is generated) to do this, but failed hard.
I know that the way to do so is to use other.gameObject.SetActive(false);
and that it probably should be in void Update()
(or void FixedUpdate
?) and an if
clause, but I can’t get this to work.
I tried searching here and with Google, but to no help. Maybe due to bad search query, but I don’t really know how to ask for this in few words. I would really appreciate your help, cause making things in Unity is great fun, but I’m really stuck here
EDIT:-----------------------
So, this is my PlayerController script that also counts pickups… well, picked up:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
public GUIText countText;
public GUIText winText;
public int count;
void Start()
{
count = 0;
SetCountText();
winText.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
if(count>=11)
{
//What goes here?
}
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Pickup")
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
if(other.gameObject.tag == "Detektor")
{
Application.LoadLevel(Application.loadedLevel);
}
}
void SetCountText()
{
countText.text = "Zebrano: " + count.ToString();
if(count >= 11)
{
winText.text = " WYGRYWASZ! ";
}
}
}
My guess is that I need to add something in the place I marked with a comment, 'cause it needs to be checked all the time and after it triggers, then it should destroy a cube named “Dzialowa”. And also i suppose that it has to be something with mentioned earlier gameObject.SetActive(false)
BTW. Sorry for some polish words in the code, I know it may be confusing a bit ;p
[1]: http://unity3d.com/learn/tutorials/projects/roll-a-ball