Quantcast
Channel: Answers for "How to make a certain object disappear after a set amount of pickups is collected?"
Viewing all articles
Browse latest Browse all 9

Answer by luna_C

$
0
0
I am going to assume you want to de-activate ( SetActive(false) ) the wall that is separating the different "maps" when the player has collected a certain numberof blocks; because I am not too sure I understand what you want correctly. 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) { wallName.gameObject.SetActive (false); } } Replace "wallName" with the name of the wall you are trying to de-activate. In this case, I think your "wallName" is "Detektor", but again I'm not too sure. You could alternatively de-activate the wall after the trigger event, when the sufficient number of block were collected: void OnTriggerEnter(Collider other) { if(other.gameObject.tag == "Pickup") { other.gameObject.SetActive(false); count = count + 1; SetCountText(); if(count==11) { wallName.gameObject.SetActive(false); } } } Again replace "wallName" with the name of your wall.

Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>