Search Unity

HELP PLEASE. I'm a novice.

Discussion in '2D' started by Alusion, Jun 4, 2015.

  1. Alusion

    Alusion

    Joined:
    Jun 4, 2015
    Posts:
    1
    Hi everyone, I need your help please.

    I'm just starting with Unity and I have been trying to do something. In Super Mario Bros World 2-1, there's a part when you hit a box from under and a 'tree' starts growing on top of the box... But I can't get it done, I mean, I do not know how to make the tree start growing when I hit the box from below, can anyone help me please?

    I have a gameobject called Mario, another called Box which has 2 colliders, one for the top and one for under, and I have the last one which is for the Tree called 'Plant' in which there is the top of the tree and it's body. Just let me know which function or anything should I use to make the tree appear after I hit the box, thanks!!
     
  2. 8bitCartridge

    8bitCartridge

    Joined:
    Feb 26, 2014
    Posts:
    144
    Hey,

    The way you described it without any code and without any snapshots its hard to tell how you REALLY got everything set up. But from what I understand, I would suggest using the Animator on the "tree" that's supposed to grow. If you are not familiar with Animations nor Animator, then read up on it at Unity docs. And, if you are familiar with it, then just make an animation that plays once when your "mario" collides with that box, make an animation of that "tree" growing and at the end of the animation set the collider on the tree to active, so mario could climb it (only after he hit the box and after it grew). Animations in Unity are extremely helpful, use them more often ;)

    best of luck!
     
  3. Limeoats

    Limeoats

    Joined:
    Aug 6, 2014
    Posts:
    104
    You're also going to want to make sure you check which side of Mario is colliding with the box (the top). This can be achieved in a few different ways, for example checking Mario's velocity in the Y direction. If he is jumping and colliding with the box, make the tree grow.
    Rough pseudo-code:
    Code (CSharp):
    1. if (velocity.y > 0 && colliding with box) {
    2.     //Make the tree grow out of the top
    3. }