Hi everyone, I’ve written a little arkanoid game and need little bit help with my powerups system.
Here’s my powerup script:
using UnityEngine;
using System.Collections;
public class PowerUpScript : MonoBehaviour {
public AudioClip[] powerupaudio;
public int PowerUp = 100;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
rigidbody.AddTorque( Vector3.forward * 2f );
rigidbody.AddForce ( Vector3.right * 3f);
}
void OnCollisionEnter ( Collision col ) {
Destroy ( gameObject );
PaddleScript paddleScript= GameObject.Find ("Paddle").GetComponent<PaddleScript>();
paddleScript.AddPoint(PowerUp);
AudioSource.PlayClipAtPoint(powerupaudio[0], transform.position);
BrickScript brickScript= GameObject.Find ("Brick").GetComponent<BrickScript>();
//powerups
foreach(GameObject pw in brickScript.powerUpPrefabs){
switch(pw.transform.name){
case "Big_Paddle":
GameObject.Find ("Paddle").transform.localScale += new Vector3(1F, 0, 0);
break;
case "More_Points":
paddleScript.AddPoint (1000);
break;
}
}
}
}
And the problem with this is that no matter which powerup you’ll take it’s always the same: Big_Paddle. So if you take more points powerup, it’s still bigger paddle powerup, what I’m doing wrong here?