Simple random setup
http_gamesalad
Member Posts: 1,340
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
'it's not working'
Too much information
Change 'actor' to 'scene'.
@sockeater22 I've changed it to scene already
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
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
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
@taiang & @jorkos
@tatiang sorry, I've never heard of a "Log Debugging Statement"
@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?
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
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
Also shouldn't you be able to just do:
Follow us: Twitter - Website
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
@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