Problems with constrain attribute vs interpolate

Goodnight GamesGoodnight Games NYCMember, PRO Posts: 184
edited August 2012 in Working with GS (Mac)
So I've been building a combo system for my game. It works by reseting to the comboTime to 15 every time the player kills an enemy (change attribute comboTime to 15). The comboTime is being constantly drained as soon as a combo becomes active.

The logic I'm using for this is:

Rule: Attribute game.comboTime > 0 then constrain attribute game.comboTime to game.comboTime -.1

The first time it runs it won't constantly subtract it will only subtract once. Every time after this however, it'll continuously subtract like it's supposed to.

I've used interpolate and this works perfectly every time except for the fact I can't reset the duration/time when a new enemy is killed as it will only go to completion.


Does anyone know a work around so I can get constrain attribute to fire right the first time it runs? Thanks!

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012

    @neondevil

    Hi, I'm thinking the Constrain Behaviour isn't right to use in this case, particularly as you want comboTime to change over time. (Although I guess there is a constraint of sorts then, but with a time value....)

    Anyway, first decide the length of time you want before the max. comboTime runs out; for instance: if this time is 7.5 seconds, then

    Rule: When comboTime > 0
    Timer: Every 0.05 seconds ----- 7.5 divided by 150
    Change Attribute comboTime to comboTime-0.1

    This can be interrupted too, if you needed, by adding an AND to the When rule, a boolean to act as an on/off switch. (Unlike the Interpolate Behaviour which you've discovered you can't interrupt... ;-) )
  • Goodnight GamesGoodnight Games NYCMember, PRO Posts: 184
    edited August 2012
    @gyroscope

    Awesome! I'm a little bit confused. So my rule would be:

    Rule: When comboTime > 0 AND boolean = true
    Timer: So for me this would be 18/150
    Change Attribute (That is inside the timer) comboTime to comboTime-0.1

    Then in my enemy I would be setting the boolean to false everytime it hits with a timer to set it back to true after like .05 seconds so everything resets?


    Thanks so much for the help!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012
    You're welcome, and you've got it, yes. :-) Except to say, you'll have to add the reset conditions. So:

    Rule: When comboTime > 0 AND boolean +true
    Timer: Every 0.12 seconds
    ---put inside timer --Change Attribute comboTime to comboTime-0.1 ---run to completion unchecked

    When boolean is false
    --if needed --- Timer After .05 seconds
    Change Attribute comboTime to 18
    ----and if you wanted the top rule to kick in again as well---
    Change Attribute boolean to true
  • Goodnight GamesGoodnight Games NYCMember, PRO Posts: 184
    @gyroscope

    So the when boolean is false change the comboTime attribute to 18 etc would go next to the rule that subtracts. Would I also need an and statement in there to make sure it doesn't go off when a combo isn't happening like:

    When boolean is false AND comboCounter(What I use to count hits) > 0 then do everything

    Or will everything be alright on that front?

    Then inside the enemy all I would be to set the boolean to false and the rest will take care of itself.


    Thanks again for this, I've been struggling with this for weeks.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012

    @neondevil

    You're welcome; I hope it works out for you... :-)

    So, presuming the Rules above are in your player; and the following is in each of your enemy's Rules:

    (I don't know if the enemy is killed by a collision or bullet, or what, but assume it's by collision):

    When Actor overlaps or collides with actor of type Player
    Change attribute boolean to false

    This will trigger the 2nd rule in the actor beginning with - when boolean is false, and includes changing comboTime back to 18 (aah, I put 15, I'll change that in a minute!) then changing boolean to true again; which, in turn, triggers the top rule to start the countdown fresh again...
Sign In or Register to comment.