Announcement

Collapse
No announcement yet.

using the tick() functiom?

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

    using the tick() functiom?

    Hello, I have a variable called energy in my custom xpawn class. I wrote a simple for loop that takes away an energy point while my exec function is runned.

    everything is peachy but for one thing.. it does it instantly.. I looked through the code and i think the tick function is the way to go. However I don't know how to use it.. Can someone help me?

    thanks

    #2
    i think you're going to have to rephrase your question. do you want it so that an energy point is taken away every, say, 2 seconds? cause then you'll probably want to use a Timer() instead. and is this being run from an exec function? because i'm not sure what you mean by "takes away an energy point WHILE my exec function...". your exec function should only run once, and very quickly...

    could you clear this up a bit and ask again?

    Comment


      #3
      if u used tick, it would decrease the energy every time the world was updated...generally more than 40 times a second, so definitely use the timer().

      Comment


        #4
        sorry about that.. i have an exec function BurstOn() that when pressed it makes the groundspeed *= 2. I also have another exec function called BurstOff(). when i press that the ground speed goes back to normal.. I have it binded like this.. alt= Burston | OnRelease Burstoff.
        I did what you suggested and made a timer function.. it counts down every second from five and it works really well. however now i have another problem.

        I want the exec function burstOn to automatically shut off when u run out of energy.. Is it wise to have all this in one exe function? or should I split it up? How would I go by making my exec function shut off when a bool variable = false?


        thank you.. does that clear it up?

        Comment


          #5
          Well, when you call your timer, set repeat to false, then check your bool in Timer, and if you still want <whatever> to operate, then call Timer again, if not, don't "renew" the timer..

          Dicky B (one way to do it)

          Comment


            #6
            I'm a little confused... what do you mean set repeat to false? return false?

            Comment


              #7
              Originally posted by kyawesker
              I'm a little confused... what do you mean set repeat to false? return false?
              No. When you start the timer, you can SetTimer(seconds,repeat) like SetTimer(1.0,true) will execute the Timer function every second, and repeat automagically. SetTimer(1.0,false) will execute Timer in one second, and not repeat automagically.

              Dicky B (I hope that clears it up)

              Comment


                #8
                I'm still having trouble.. I thought I could do it where i have a set speed. like 510.00000 when you are "bursting" then when your energy goes down to 0 it would reset your speed to 320 or whatever.. however, now my energy will never go below 2.. i don't get it..

                Code:
                 event PreBeginPlay()
                {
                 SetTimer(1.0,true);
                 }
                
                
                Function Timer()
                {
                
                if(bPressed && energy > 0)
                {
                energy--;
                }
                if(bPressed && energy < 5)
                {
                
                energy++;
                
                 }
                 }
                
                exec function BurstOn()
                {
                    bPressed=true;
                  Timer()
                bPressed=false;
                
                }

                Comment


                  #9
                  Well i dont know how you are doing this but it seems a little weird..
                  Code:
                  //clear out post begin play
                  
                  
                  exec function BurstOn()
                  {
                  if(Energy > 0.1)  //energy minimum
                  {
                   SetTimer(0.1,true);
                   bBursting = true;
                   bRecharging = false;
                  }
                   //set to higher movement rate
                  }
                  
                  function Timer()
                  {
                  if(bRecharging && Energy < EnergyMax)
                  {
                  Energy += RechargeRate; //alter this to desired
                  if(Energy > EnergyMax)
                  {
                  Energy = EnergyMax;
                  bRecharging = false; //not needed
                  SetTimer(0,false);
                  }
                  }
                  
                  if(Energy <= 0.0)
                  {
                  SetTimer(RechargeRate,false); //recharge reate here of mine (thinking 1 second).
                  bRecharging = true; 
                  bBursting = false;
                  }
                  else if(bBursting)
                  {
                    Energy -= 0.1; //0.1 is the setting in the burstOn timer... just how qucik you take away energy
                  }
                  }

                  Comment

                  Working...
                  X