spawn actor

Hello, I want to make an actor who appears in the game at a random time, for it put an actor spawn and put each random (0.7, 2) display the actor, because what it does is that when you start the game creates the actor randomly from these ranges but the actor will always generate the same time. What I do is constantly generating this actor between those intervals but differently each time every second interval to take a different actor each time out differently. I do not know if I explained well and if I will understand because my English is not very good. Javier

Comments

  • Thunder_ChildThunder_Child Member Posts: 2,343
    edited December 2013
    I think what you are doing is you have your timer set to "for" 07,2 instead of "after"...use after...that way it will choose an integer between .07 and 2 (spawn actor).....I believe this to be the solution
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2013
    I think what you are doing is you have your timer set to "for" 07,2 instead of "after"...use after...that way it will choose an integer between .07 and 2 (spawn actor).....I believe this to be the solution
    Neither. To spawn an actor every few tenths of a second you'd need to use an EVERY timer.

    The problem here is that GameSalad can't change a timer value once the timer has started. So even though it seems to make logical sense to do this:

    Timer every [random(0.07,2)] seconds
         spawn actor [actor name]

    That will just choose a random value once (for example 0.39) and use it over and over. The other issue is that the random() function only accepts integers. So really, it won't even work once. To get a value between 0.07 and 2, you'd need to use the expression random(7,200)/100.

    Instead, do this:

    Create a real attribute called game.spawnTime.
    Add the behavior: Change attribute game.spawnTime (real) to game.Time+random(7,200)/100
    Add the rule: When attribute game.Time=game.spawnTime
                                spawn actor [actor name]
                                Change attribute game.spawnTime (real) to game.Time+random(7,200)/100

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

  • tarsiustudiotarsiustudio Member Posts: 130
    thank you very much @tatiang have done what you said it works perfectly, thanks again for your help ^:)^
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @tarsiustudio You're welcome!

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

Sign In or Register to comment.