Hi guys I’ve been working on my own 3d Plat former for about a month. In my game i want to have it so you cant pass the level without collecting a certain amount of game objects. But i don’t know how to code.so far you can collect the game objects, and at the end of the level their is a cube that is a collision that allows me to go to the next level, but as i said before i want it so you can only pass by collecting a certain amount of game objects. Here is my code for it
void OnCollisionEnter(Collision collision) { if (collision.gameObject.name == “Cube”) { Application.LoadLevel(“level2”); }
public int pointrequirement //amount of points you need to get to pass the level
public int points //amount of points that you have
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.name == “Cube”&&points>=pointrequirement)
{ Application.LoadLevel(“level2”); }
else if(collision.gameObject.name==“Point”){
points+=1;
Destroy(collision.gameObject);
}
That should work,just create a new GameObject with trigger collider and change its name to Point,then set the pointrequirement variable to the number of points player needs to get to finish the level.
Any help plz would mean a lot thankyou