Set Animation from global variable?

Get help using Construct 3!

Post » Mon Oct 09, 2017 12:02 pm

Hi, I'm trying to set the animation of a sprite based on a global variable. I've set up a Player sprite with an animation called "playerA".

I've set a Global String SelectedPlayer = "playerA", and try to use this On Start on Layout like this:

Player Set animation to SelectedPlayer, but this is not working.

If I do Set animation to "playerA" it works correctly, but I need to set this dynamically via variables.
If I alert the SelectedPlayer string it says "playerA", so the variable is available and correct. Is this a bug?
B
4
Posts: 6
Reputation: 212

Post » Mon Oct 09, 2017 5:36 pm

It's a bug...with your code. Can you post a screenshot or share c3p to see where it's gone wrong, thanks.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Tue Oct 10, 2017 6:47 am

Message: machineboy can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi, thanks for your reply.

I made an example using the endless runner template:

https://www.dropbox.com/s/9sqvdlocg32qz ... g.c3p?dl=0

If you change the Set Animation to "playerA", the animation works, but setting it to selectedPlayer (the global string variable with "playerA" value) it fails.

Edit: can't post urls yet, so try after .com/ please paste s/9sqvdlocg32qzkn/animationBug.c3p?dl=0
B
4
Posts: 6
Reputation: 212

Post » Tue Oct 10, 2017 7:25 am

Where you've set the global variable, take "playerA" out of the quotation marks.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Tue Oct 10, 2017 10:50 am

Aha, so strings should never have quotation marks around them when setting them?
B
4
Posts: 6
Reputation: 212

Post » Tue Oct 10, 2017 3:33 pm

Nope, you set the type to string with another field.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823


Return to How do I...?

Who is online

Users browsing this forum: Ashley, mcscooter, shinkan, signaljacker and 1 guest