Make actor jump at random intervals between .5 to 1.2 seconds?

I currently have an actor that jumps every .9 seconds for .2 seconds at a time. The other day i tried using the random(min,max)
function for ranges of jumps between .5 to 1.2 seconds. It seems it doesn't really work for anyone on the forums. I'm not trying to spawn anything like everyone else i just want it to jump at different intervals. Any help is appreciated!

Comments

  • ArmellineArmelline Member, PRO Posts: 5,458
    Something like this? I've just used a display text instead of a jump, but the timing should work fine. I found (using the latest nightly, so might be that) that applying the /10 to the attribute always resulted in 1 for some reason, but works fine when applied to the timer.
  • ArmellineArmelline Member, PRO Posts: 5,458
    oops, wrong screen shot :D You need stick the jump/display text into the timer and set it up FOR 0.2s.

    Can't edit the screen shot... Damn forums :D
  • ArmellineArmelline Member, PRO Posts: 5,458
    Hopefully this is the correct one...
  • izzydoghamizzydogham Member Posts: 24
    is random an integer attribute ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    is random an integer attribute ?
    In that screenshot, it is.

    You could also choose to make self.random a real attribute and then do Change Attribute self.random to random(5,12)/10 and use self.random as the timer frequency.

  • izzydoghamizzydogham Member Posts: 24
    Hopefully this is the correct one...
    Hmm didn't quite work for me... Can you have it for jumping instead of text and screenshot it?

  • ArmellineArmelline Member, PRO Posts: 5,458
    You'll need to post your current code before I could make such an adjustment. You could be doing the jumping in 10 different ways :D
    is random an integer attribute ?
    You could also choose to make self.random a real attribute and then do Change Attribute self.random to random(5,12)/10 and use self.random as the timer frequency.
    GameSalad pumped out a 1 for a real for me when trying that. Maybe it's a bug. But that's why I put the /10 in the timer rather than the change attribute. Same result, but that way it actually worked :D
  • izzydoghamizzydogham Member Posts: 24
    edited February 2014
    how do i add a screen shot...? :/
  • ArmellineArmelline Member, PRO Posts: 5,458
    edited February 2014
    Ah, think attaching files is for pros only. Try uploading it to http://www.imgur.com.

  • izzydoghamizzydogham Member Posts: 24
    Your'e the best btw http://imgur.com/qZ8IK53
  • ArmellineArmelline Member, PRO Posts: 5,458
    Okay, three issues there. Firstly, you can't use 0.5 in a random() function. The minimum is 1. That's why I used random(5,12) and then divided it by 10. Take another look at my random attribute and timer function.

    Secondly, you have the second timer - the one containing the move behaviour - set to EVERY instead of FOR. It needs to be set to FOR. What you're saying is that every 0.5-1.2 seconds, do the jump after 0.5 seconds.

    Thirdly, with a move behaviour in there you need to have the second timer's "Run to completion" option checked.

    A fourth thing worth considering is that if you have a lot of random numbers generated in the 0.5-0.7 range, your actor won't have time to fall back down. With 0.5-1.2 frequency and 0.5 duration, a lot of your jumps will be coming one straight after the other. I'd lower the jump duration and increase the move speed, perhaps.

    Realistically, the difference between 0.5 and 1.2s is hardly noticeable to the user. Maybe increase those a bit. Really depends on exactly what you're trying to do though.

    Attached is an updated screenshot of the rules. I'm assuming your scene has gravity, else the actor won't be jumping so much as move upwards a bit at a time :D
  • izzydoghamizzydogham Member Posts: 24
    Hey! it kinda works, in the beginning of the program it chooses anything from .5-2.2 but then it stays the same integer for every jump. I would like it to jump randomly every single time it jumps. So sometimes it jumps .6, sometimes 1.3 etc. IS that possible?
  • ArmellineArmelline Member, PRO Posts: 5,458
    Mine does that (for me at least). The first change attribute, outside of the timer, sets the initial random jump time. The second change attribute, inside the timer, makes a new random value for each following jump.

    Really not sure what your problem might be now. Can you post your rules again?
  • ArmellineArmelline Member, PRO Posts: 5,458
    Force it to reset the timer with a change attribute then. See attached. Ignore the random(10,60), I had to make the values higher to be able to better see if it worked. You can change them to your lower values, no problem.
  • izzydoghamizzydogham Member Posts: 24
    You helped me out so much thank you !!! You have apps of your own that i can download?
  • ArmellineArmelline Member, PRO Posts: 5,458
    You helped me out so much thank you !!! You have apps of your own that i can download?
    In my signature. I use GameSalad more as a kind of ever-refilling puzzle than anything though. I make any games but most need graphics I cannot provide, so I don't release all that many :D

    Plus I get bored of things as soon as they hit version 1.0 :P

    Glad I could help though!
Sign In or Register to comment.