How do you add a value to a variable from a string?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have one object with multiple animations and a variable with a value for each animation. when the player presses space to pick the object up I want to add 1 to the variable by using the animations name because the animation and variable have the same name. But the only issue is construct 3 wont allow you to add to a variable unless you select one from the drop down is there a way around this without having to test which animation is playing when the player is overlapping the object. Thanks so much any help is appreciated.

  • A super simple way to put this is on keypress space now when you go to add one to a variable instead of choosing from a drop down of global variables that exist in the project you could put an expression in for the variable name and you would put for example sprite1.animationname then value +1 if that makes sence.

  • Mixing the graphics with the game logic is usually a very bad idea. You want to separate them, to allow both to live in their own world, so in case you want to change an animation name or a variable name it doesn't mess up your whole project.

    Don't focus on how to achieve this particular task, what is your overall objective ? Why do you need to bind variables to animations ? What are you trying to achieve?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright thanks zed 2100 that makes sense. I appreciate your help immensely!

  • Whether you're a programmer or not, it's a good idea to know more about the MVC (model view controller) design pattern. It's widely used in the software and game dev industry. Google it.

    PS: in order for a forum user to be notified of your response, type their nickname prefixed with For example: Zed2100

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