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

Get help using Construct 2

Post » Wed Nov 23, 2016 9:26 pm

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:
Image

i hope someone can explain my mistake, thanks in advance! :)
Current project: *Retro Dude vs. Evil Meanie*
If you like my art- or games-stuff, check out my twitter *Link* for more!
You can also find an assetpack I made here: *Link*
B
14
S
2
Posts: 20
Reputation: 740

Post » Wed Nov 23, 2016 11:32 pm

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.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Thu Nov 24, 2016 11:54 am

Thank you very much @randomly

it doesnt work though^^
here is what i did following your instructions:
Image

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:
Image

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! :)
Current project: *Retro Dude vs. Evil Meanie*
If you like my art- or games-stuff, check out my twitter *Link* for more!
You can also find an assetpack I made here: *Link*
B
14
S
2
Posts: 20
Reputation: 740

Post » Thu Nov 24, 2016 5:57 pm

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

I thought you were trying something different.
Anyways, this works:
Image

Here is the .capx in case you need it:
Download
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Thu Nov 24, 2016 7:42 pm

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 :D

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
Current project: *Retro Dude vs. Evil Meanie*
If you like my art- or games-stuff, check out my twitter *Link* for more!
You can also find an assetpack I made here: *Link*
B
14
S
2
Posts: 20
Reputation: 740

Post » Fri Nov 25, 2016 2:55 pm

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)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Fri Nov 25, 2016 10:29 pm

Ahh, now i understand some problems i had earlier.

It's really nice of you to help me so much thanks again *thumbs up* :D
Current project: *Retro Dude vs. Evil Meanie*
If you like my art- or games-stuff, check out my twitter *Link* for more!
You can also find an assetpack I made here: *Link*
B
14
S
2
Posts: 20
Reputation: 740


Return to How do I....?

Who is online

Users browsing this forum: Armench, Yahoo [Bot] and 19 guests