BlockBreaker tuning

So, i’m trying to figure out how to add one of my favourite powerups from arkanoid et al - guns. used to be you’d hit a powerup and then for like 30 secs you’d be able to shoot from your paddle to help break blocks whilst bouncing your ball.

Anyone done this? Have any advice for doing this?

Been a while since I did the course, but a couple ways exist. You would want to start with spawning either a particle or just another game object as the bullet. I suggest giving it a finite life, or another shredder at the top to destroy them.

Then you could apply movement and check for collision. Probably on the tag, so you don’t shoot your ball

Thanks bryant. Im not sure i could lay down the code for that. but at least I know! Thanks!

honestly im having trouble figuring out how to add certain blocks that are powerups anyway.

You could start simple. So a power up would drop either random or from a box that is destroyed. You could do a random % chance then again spawn the power-up block and let it fall, much like the ball does.

When the paddle catches it, so something. Maybe start simple and resize the paddle a bit, you could make the ball faster too, it then you would need to call a function on the ball

I’ve managed to get a sort of powerup working so far through trial and error. my code is ugly as sin, but it does at least spawn a second bat and kills it after 20 seconds. But trying to get it to spawn correctly is a challenge. it always spawns ontop of the current paddle. when i try to alter the transform it spawns in the same place.

Summary
public class PowerUpScript : MonoBehaviour
{   
    enum powerUpType {NONE, MULTIBALL, EXTRALIFE, BIGPADDLE, TWOPADDLE};
    [SerializeField] powerUpType PUType;

    //Cached References
    LevelController level;  // so that block can call the lvel controller script class
    GameSession status; //to adjust game statuses
    [SerializeField] GameObject block;
    [SerializeField] GameObject paddle;
    [SerializeField] GameObject ball;

    //state variables    
    bool blockDestroyed;

    public void getSpawn()
    {
        PowerUpSpawn();
    }

    private void PowerUpSpawn()
    {
        if (PUType == powerUpType.TWOPADDLE)
        {
            Vector2 paddlePos = new Vector2(paddle.transform.position.x, paddle.transform.position.y);
            GameObject Paddle2 = Instantiate(paddle, paddlePos, transform.rotation);
            Paddle2.SetActive(true);
            Destroy(Paddle2, 20f);
        }
    }
}
``

`
So yeah… not sure whats happening.

Still don’t really know whats going on here. My code should, i thought, create a new paddle 2 points to the right of my original paddle. As you can clearly see here, the power up spawns ON TOP of the orignial paddle. This is not what I want to do. Is anyone able to help with this. my code is this ::

>   private void PowerUpSpawn()
>     {
>         if (PUType == powerUpType.TWOPADDLE)
>         {
>             Vector2 paddleLoc = new Vector2(PaddleLocX + 2, PaddleLocY); 
>             GameObject Paddle2 = Instantiate(paddle, paddleLoc, paddle.transform.rotation);
>             Paddle2.SetActive(true);
>             Destroy(Paddle2, 20f);
>         }
>     }

my result is this ::

Thats… not right…

Hi Kheldarath,

First of all, good job on challenging yourself. :slight_smile:

Secondly, have you already tried to add Debug.Logs to your code to see what is going on during runtime? Log the position of the original paddle into your console, then paddleLoc. Maybe the values are not what you think they are.

1 Like

Privacy & Terms