Random only up and down direction actor

Hi!
How is possible make an actor that can use random up and down direction every 0,5 seconds???
I make an Time every 0,5 seconds but in directions what have I put (is a behavior "Move")?

Thanks in advance!

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Move, Change Attribute, Constrain Attribute or Interpolate would all work
  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    Direction: (left and right)

    Random (0,1) * 180


    . . . . . . . . . .

    Direction: (up and down)

    (Random (0,1) * 180) + 90

    . . . . . . . . . .
  • aitor010aitor010 Member Posts: 282
    hi!
    Thanks by reply @KevinCross and @Socks , I have this:
    http://s2.subirimagenes.com/imagen/previo/thump_869535420131113-18.png
    And not run... :( What I do bad?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    So surprised you didn't use sin/cos, Mr. @Socks.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • aitor010aitor010 Member Posts: 282
    @tatiang how can I do the good expression?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    That expression in your screenshot is meant to go in the direction box, not the speed one.
  • aitor010aitor010 Member Posts: 282
    Gamesalad show me an error in screen when run the game: http://s2.subirimagenes.com/imagen/previo/thump_869540120131113-19.png

    The expression is: (Random (0,1) * 180) + 90

    I change the expression of sped to direction (was a wrong)
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Remove the space between random and the brackets, and maybe make it lower case, although it may not be case sensitive
  • aitor010aitor010 Member Posts: 282
    same error I test with: (Random(0,1)*180)+90 :(
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Like I said try lower case r, and also make sure you're typing it in the black expression window by pressing the e button, and not straight in the text box.

    It also helps if you understand what it's doing before you put in someone's suggestion as you'll never learn, and will never be able to modify it without breaking it.
  • aitor010aitor010 Member Posts: 282
    ok, problem solved, not show error display but my actor not move.... I write expression type to type click on random and after the numerics.... but not run....
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I noticed that if I put the random expression in the Direction field, the actor doesn't move but if I use a separate attribute it works. Try this:

    image

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    So surprised you didn't use sin/cos, Mr. @Socks.
    @tatiang

    I was very tempted to :) ! In fact if I wanted an actor to move randomly up and down I'd use sin/cos simply because you can get a nice dampening effect when you change direction, rather than a sudden sharp direction change.
  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    I noticed that if I put the random expression in the Direction field, the actor doesn't move but if I use a separate attribute it works. Try this:

    image
    Yep, that works perfectly.

    I don't think you need the initial change attribute (direction to 270°) it works fine without that ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Socks, the initial change attribute is simply because by default the value of that attribute is 0, which moves the actor to the right instead of up or down.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    @tatiang
    @Socks, the initial change attribute is simply because by default the value of that attribute is 0, which moves the actor to the right instead of up or down.
    Ah! I understand now !

    (I quickly copied your set up, but I just entered 90° as the initial attribute value)

    image
Sign In or Register to comment.