How do I temporary change variables and revert it back

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Good day, C2 community!

    Say, I have a RPG Hero with stats: Atk, Def, and so on. And a Hero have an item that can be activated and deactivated at any time by pressing the button.

    I need to do the following: when an item is Active, the Hero have temporal stats changes: +2Atk/+1Def and so on, and when item is Inactive, the Hero have its initial stats.

    I've tried to use "while" loop:

    While [item is Active] Atk = initial Atk + bonus[/code:2xgic75x]
    and System-Compare Values event:
       [code:2xgic75x]itemIsActive = 1
       Atk = initial Atk + bonus[/code:2xgic75x]
    but I get the same result: in every tick Atk increases at "bonus" value. I understand why it happens, but this is not what I need 
    So, please help me. Thank you.
  • your second approach is fine. Just add a condition system > trigger once while true

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • fm4fanAT, thank you very much! It works fine now. As I understand, I have to do the same thing to remove temporary effect:

    itemIsActive = 0
    Trigger once
       Atk = initial Atk - bonus[/code:2ug5v6st]
    Correct?
  • correct

    but in this case

    itemIsActive = 0

    Trigger once

    Atk = initial Atk

    You can also use only 2 variables and get rid of the "initial Atk". Then you would do Atk = Atk - bonus to get back to normal

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