Search Unity

Make objects with specific script follows an object with the same script

Discussion in 'Scripting' started by tetriser016, Oct 15, 2017.

  1. tetriser016

    tetriser016

    Joined:
    Jan 3, 2014
    Posts:
    100
    I want to work on my brick-breaker prototype that's similar to Block Breaker 3 Unlimited, but I don't know how to make other balls follow the ball that touches the arrows. I've tried to use transform arrays, but it keeps being screwed up.

    Here's the gameplay of BB3U:


    How can I achieve this properly?
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    I'm not going to watch the whole video because you didn't mention a specific time that it happens, so I'm not entirely sure what you mean, but I'm going to assume you mean at the end of the level when a sort of escape path opens up and all the balls leave the game area.

    You can just use a set of triggers by the escape path arrows. Once one ball touches the trigger, tell all balls to leave the play area via a the specific path designated by the trigger itself. You can use a simple state machine inside the BallController script:
    Code (csharp):
    1.  
    2. enum BallState { Playing, Leaving };
    3.  
    or alternatively, disable the BallPlayingController component and enable a BallLeavingController to handle the logic instead.