Spawning random actors with same spawner tutorial – Please help
Village Idiot
Member, PRO Posts: 486
Can someone PLEASE either point me to a tutorial that makes it clearer for a beginner to make this happen, or give further instructions? I found the instructions (below) in the forums but I don't know how to implement this – being a beginner.
Change attribute X to random(1,10)
Rule, if X = 1
Spawn Actor 1
Rule, if X = 2
Spawn Actor 2
Rule, if X = 3
Spawn Actor 3
Rule, if X = 4
Spawn Actor 4
Rule, if X = 5
Spawn Actor 5
. . . .etc
Comments
I don't have a tutorial but what those rules are saying is:
Create a spawner actor and in that actor add a behavior that will choose a random number between 1 and 10. This would be able to spawn up to 10 actors, if you want to spawn only 2 actor you would make this 'random(1,2)'.
Then each rule under that will spawn the appropriate actor so Rule one watches if the random number 1 was picked, if it was is spawns actor 1.
If the number 2 is picked it will spawn actor 2, and so on...
You need to create the spawned actors as well of course.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Here is a sample project that spawns two actors at random every .5 seconds.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thanks but I was trying to make the one spawner spawn different actors from the same position. Basically, I'm trying to have the random actors slide from right to left as if a canon were firing different objects.. if that makes any sense.
Yeah it makes sense, the sample file was to show you how to spawn different random actors from one spawner. I spawn them in random spots for the sake of the demo, you can change where they are spawned within the individual spawn behaviors using the X and Y offset values. The right and left arrows where I have Random numbers, you can put any values in there you want.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
oh. ok.. I'll have to get stuck into it and see if I can make it work. I'm not from a programming background and am new to this – it seems more complicated than I thought it would be. I'll have a go and fingers crossed I'll get it to work. I've been going nuts over this for days.
I'm sure you'll get it. Once you connect with how the logic of Gamesalad works it all falls into place.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
First make a new attribute for your actor, let's call it 'X' (it can be called anything you like).
. . . . .
Then place a Change Attribute into your actor, set it up so that it is changing X to random (1,10) - _which is a random number between (and including) 1 and 10 _
. . . . .
Then beneath this Change Attribute behaviour create a rule that reads:
When All/Any conditions are valid
Attribute: X = 1
. . . . .
Then into the 'Drag your behaviours here' section drag a Spawn Actor behaviour.
In the Spawn Actor behaviour change 'Actor:' to actor 1.
. . . . .
Now duplicate this whole rule (which contains the Spawn Actor behaviour) 10 times.
Now change each of the conditions to an appropriate number (Attribute: X = 1 / Attribute: X = 2 / Attribute: X = 3 / Attribute: X = 4 . . etc) . . . .
Now change each of the Spawn Actor behaviours to an appropriate actor (change 'Actor:' to actor 1 / change 'Actor:' to actor 2 / change 'Actor:' to actor 3 . . . etc)
I've attached an updated demo that uses the same actors as the last one. This time the spawner is on screen and shoots the two random actors out from it. The movement of the green and blue actors is controlled in each of those actors after they are spawned to screen.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I think that's exactly the mechanics I'm trying to achieve! I'll get into it when I get my next bit of time. Late where I live now. I wish I could jump into it! I'm quite excited but alas, I have to be up in 6 hours for work. I'll let you know how it goes if you like.
@monkeyboy simian, Damn work always getting in the way of free time!
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
thanks guys this thread has been really useful to me! I looked at the first example that Jamie posted and that was really useful - i pretty much did the same in my game - I've put every 0.5 seconds spawn random numbers but it doesn't seem to do it every 0.5 seconds - theres a few gaps ? does anyone know why?
@Sarahbush What's happening is that the random number generators sometimes repeats numbers (e.g. 3, 4, 4, 7) and rules that check for a change in value do not trigger when the value repeats. See my demo for a solution to this: http://forums.gamesalad.com/discussion/comment/513319/#Comment_513319.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
thanks ill take a look @tatiang