Simple random setup

I have tried to make a simple random setup for my spawner

Timer
every 2 seconds
change attribute
game.random x to (-100,800)

then I put the random x in the x position of the spawner & it's not working.
Any other suggestions for simple random spanwer?

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    'it's not working'

    Too much information :p

    Change 'actor' to 'scene'.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @sockeater22‌ I've changed it to scene already
    Image and video hosting by TinyPic

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    1. Where is the Spawn Actor behavior?
    2. Add a Log Debugging Statement to the actor you're trying to spawn and change the expression to self.Position.X. Then open the Debugger window and see if a value appears when you Preview the scene. Next, drag the (spawned) actor onto the scene and Preview. Does a value appear in the Debugger?

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

  • jorkosjorkos Member, PRO Posts: 353

    this method does not work - "every 2 seconds do some random thing". you will always get the first answer.

    you need to change an attribute every 2 seconds and when that attribute is changed, trigger the random function

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    @jorkos said:
    this method does not work - "every 2 seconds do some random thing". you will always get the first answer.

    you need to change an attribute every 2 seconds and when that attribute is changed, trigger the random function

    @jorkos That's not correct. Try it and you'll see that it generates a different random number every two seconds. I think you might be confusing this with the issue where you use a random value for the timer duration and the duration doesn't change each time.

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

  • jorkosjorkos Member, PRO Posts: 353

    oh yeah @tatiang you are right! sorry. the problem is that the original spawner actor is not triggering an action to load the new value, it loads it once and that is it.....lots of ways to solve this but that is the basic issue

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @jorkos said:
    The problem is that the original spawner actor is not triggering an action to load the new value, it loads it once and that is it.....lots of ways to solve this but that is the basic issue

    There's not really a need to "load the new value" or "[trigger] an action" though I think I get what you're saying. The main issue is that there is no spawn behavior in the image that was posted. If there was a spawn behavior inside of the timer and below the change attribute, it would work.

    Anyway, I guess we'll have to wait for @http_gamesalad to post a response.

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

  • http_gamesaladhttp_gamesalad Member Posts: 1,340
    edited January 2015
  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @tatiang‌ sorry, I've never heard of a "Log Debugging Statement"

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @tatiang‌ do you mean make an actor, put a display text in it, then put the game.random X & put it on the screen & see if that value changes?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Hmm, that should all work.

    The Mac version of Creator has a behavior called "Log Debugging Statement." I just assumed the PC version did, too.

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

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited January 2015

    @http_gamesalad said:
    Image and video hosting by TinyPic

    taiang & jorkos

    That logic is incorrect. You are changing the self.spawned to true before the actual spawn occurs in a ruleset reliant on the self.spawned being set to false in order to trigger.

    A simple fix would be to add a timer. So something like after .1 seconds change self.spawned to true

    Follow us: Twitter - Website

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    Also shouldn't you be able to just do:

    Every 2 Seconds
    
    spawn actor
    from position random (x,x), y
    

    Follow us: Twitter - Website

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    Oops, right @AlchimiaStudios‌. I started to write that the change attribute needs to come at the end of the rule and then got distracted.

    And yes, there's no reason to need to change the random value in a separate actor. Just use random(-100,147) in the x position field of the Spawn Actor behavior.

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

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Alchimia Studios‌ Okay so what I did is put every 0 seconds change attribute self.spawned to true (I want a continuous stream.) & I don't understand what you mean by "Also shouldn't you be able to just do:

    Every 2 Seconds

    spawn actor
    from position random (x,x), y

Sign In or Register to comment.