Announcement

Collapse
No announcement yet.

Question about character movement and storing variable value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question about character movement and storing variable value

    Hey guys, I managed to make my character move X amount of units and then stop when i press a button(essentially moving from one tile to another) but I can`t seem to find a way to control the time that he takes to move from one tile to another as well as making him interpolate between tiles (he is simply snapping from one tile to the other). I tried messing around with the delta time on the Vector 2DInterpTo (changing the delta time only seems to decrease the amount of units the character moves when pressing the button) and Event Tick node but i cant manage to make it work. Can anybody shed a light on my problem?

    I will attach my current node set up on this post.

    Also, is there a way for me to store the value of a variable in a set period of time? For example: Checking the health of the character when he gets hit, then checking it again after 4 seconds and comparing the 2 values.

    Cheers o/
    Attached Files

    #2
    You're not really using that interp to node as intended. Try plugging a 'world delta seconds' node into Delta time and then changing the interp speed will change the speed the character moves.

    As for storing and comparing variables, you can do this by setting then comparing variables, either with timelines, delay functions or regular delays, but if you are comparing health, why not do it on receive damage? Is there a reason you need it to constantly check every 4 seconds?

    Comment


      #3
      Hey man, thanks for the tips, ill try them as soon as i get home o/
      As for the 4 seconds, I wanted to check if my character received X amount of damage on a set period of time, and if he did, he would get stunned; Also, if the character doesn`t take any damage for some time, the counter for amount of damage that he would have to receive to be stunned would reset to zero.

      Cheers.

      Comment


        #4
        I would avoid checking every 4 seconds, you would probably rather need to check the previous 4 seconds from any given attack.

        So this can all be done on the receive damage event.

        You will need to set up a Struct with 2 variables, a float for DamageReceived and TimeReceived. Create an array on your character set to this struct you create, I'll call this 'DamageHistory' for now. You will also need a DamageTally float variable.

        When you receive damage, add an entry to your Array 'DamageHistory' and set the respective values to the. The time can be set with the 'GetGameTimeInSeconds' node.

        Then run a for loop on your array and if GetGameTimeInSeconds -TimeReceived <= 4 is True then add to the 'DamageTally' float variable. If False, remove from Array.

        On the for loop complete, if DamageTally >= StunnedValue, then stun. Then either True or False, reset Damage Tally to '0'.

        If you want to clear the attach history after a successful stun, then also clear array on True.
        Last edited by Trippy; 04-18-2017, 05:36 PM.

        Comment


          #5
          Here is a screenshot, tested and seems to work fine. Set your StunnedValue to however much damage causes a stun.

          Click image for larger version

Name:	StunTimer.PNG
Views:	1
Size:	219.9 KB
ID:	1126589

          Comment


            #6
            You could probably move the set DamgeTally to 0 at the very start, directly after Event AnyDamage instead of at the end. Doesn't really matter but might be neater.

            Comment

            Working...
            X