Forum rules - please read before posting.

How do i trigger grass collision animation when user walks through it?

Hi, i'm fairly new to this and need some help please.

I see many examples of environments where the grass, flowers etc play an animation while a user walks through them. I was wondering what is the best way of achieving this with AC and without scripting.

I have my grass sprite, i have an animation and a controller, i added a component Box Collider 2D with "is trigger" activated.
But then what?
How i trigger the animation every time the player walks through the grass.
By using a trigger 2D, a hotspot or with box collider? and where i set the action for it?

What is the most efficient way of achieving foliage collision animation?

Thanks
Kappa

Comments

  • Welcome to the community, @kappa.

    If you want to completely avoid scripting, use a Trigger 2D. If you're not looking to have the grass be clickable, you don't need to involve a Hotspot.

    Since you already have a GameObject with your sprite, animator controller, and collider, you can attach an AC_Trigger component to it to make it an AC Trigger.

    You may need to play around with the various settings on it, but I'd suggest starting with having it react to the Player "On Enter". The Trigger's Actions will then run when the Player enters the collider's boundary. To play an animation when this happens, use an Object: Animate Action. If you want to play the animation directly by entering in its name, set the Animation engine to Sprites Unity. If you want to play it by manipulating an animator parameter, set it to Sprites Unity Complex or Mecanim.

    By default, an AC Trigger requires the colliding object (in this case, your Player) to have both a collider of their own (this too can be a trigger), and a Rigidbody2D. The Actions will then run when the two colliders intersect.

    However, you can instead set the Trigger's Detection method field to Transform Position, so that you don't need either of these components on the Player - and the Actions will run when the player's position is inside the Tigger's collider. More on this can be found in the "Triggers" chapter of the Manual.

  • edited June 2019

    Chris thank you so much, it worked.
    Before, i was using the wrong Animation engine.
    I now used Mecanim and after playing around with settings i achieved the desired effect.
    Also i used the AC_Trigger.

    AC is fantastic.
    Great community too, i'm here to stay.
    Again thank you so much.
    ;-)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.