How do I do a grass animation upon leaving the "tile"

0 favourites
  • 7 posts
From the Asset Store
Create an awesome world for your RPG top-down game with this Tileset
  • Hi,

    I guess this is pretty easy to solve, i cant figure it out though:

    Its a bout a top-down rpg. There are grass objects i wish to animated upon the player leaving the object (player and grass not overlapping anymore), i.g. a little wavy animation.

    It doesnt work though if the player leaves one grass object and directly moves into another grass. I tried picking the specific UID and only checking the overlap for this one but it didnt work.

    Screenshot:

    i hope someone can explain my mistake, thanks in advance!

  • Do the following:

    • add a "function" object
    • put everything underneath and including "Pick instance with UID" in a function, so under the event "On function [...]"
    • Replace "set grassanimationUID to grass.UID" by "Call function [...]" with the parameter "grass.UID" (replace [...] by the function's name)
    • Replace "GrassAnimationUID" in the "Pick" event by "Function.Param(0)"
    • add a "For each "grass"" to the "is overlapping" condition

    This should work.

    If you need more help or more explanation, either just tell me or provide a link to your .capx and I'll fix it for you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you very much randomly

    it doesnt work though^^

    here is what i did following your instructions:

    to be honest, i dont rely get how this would help me since its only calling the function on overlapping with grass, while i like to play the animation upon not overlapping anymore.

    I made a little picture to show you exactly how i want it to turn out:

    Basically what im trying is, to play the animation only on the one grass object the player was previously standing in, after leaving this object.

    I guess the problem is that i cant figure out how to properly check if the player is overlapping a specific (UID) grass object instead of any.

    I dont feel comfortable sending the whole project as a capx, but if this wasnt enough i might recreate the problem in a new file.

    Thank you in advance again!

  • Now I see where you want to go, that image explanation helped a lot.

    I thought you were trying something different.

    Anyways, this works:

    Here is the .capx in case you need it:

    Download

  • It works now! Thank you so much for your effort!

    I didnt know the pick by evaluation condition and thanks to you learned something new

    It only works if "lastUID" is global though, i was really confused because i had it as a local variable at first, would you mind explaining me why? thats minor though

    anyway thanks again

  • Actually, if you use just the grass effect in just one layout, you can use a local variable too.

    The global variable is accessible in the whole project, while the local variable is just accessible in the appropriate group.

    Also, a global variable is always static while you can set a local variable to not be static.

    ("static" means that the variable always stays to what you set it. If a local variable is not static, it will reset to its default value every tick. That might have been the reason why it didn't work for you. If you want to use a local variable, make sure to set it to static)

  • Ahh, now i understand some problems i had earlier.

    It's really nice of you to help me so much thanks again *thumbs up*

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)