My random object spawner won't work and I have no clue why
metalasus
Member Posts: 6
in Help Wanted
I'm creating a simple endless runner game, in which I'm trying to make obstacles appear at set intervals, randomly choosing which. However, my obstacle spawner isn't behaving like I expect it to. Is there a way I can attach a game file so that everyone can look at it and help? Thanks, I really appreciate it.
Comments
You can upload it to a file-sharing site and then post the download link here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I don't think I've ever used one of those before. Any specific ones come to mind?
thanks
Yes... I am also having this issue. my obstacle spawner occurs an error every time i try to use it. Please help me to resolve this issue mobdro.
can't you just attach the file to your message by clicking the attach file icon above the text box?
You can put a link there, but you can't attach a .zip file
You have to be a pro member of the forums to post an attachment such as a .zip file.
Google file sharing site for examples.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
ah i see
ok, here's the link to my project. I'm mostly concerned about why my actor called 'object spawner' doesn't spawn obstacles as it should.
filedropper.com/turbotimmk4
I imagine what's happening is that the obstacle spawner is only occasionally spawning an actor instead of spawning one EVERY three seconds... is that correct?
If so, it's because of the way rule conditions work in GameSalad. Rules only "fire" when the rule condition changes from false to true. So if self.obstacleNumber was 1 and becomes 2, it will trigger the rule for when self.obstacleNumber equals 2. But... if self.obstacleNumber was 1 and then changes to 1 again (after three seconds), that rule for when self.obstanceNumber equals 1 will NOT fire. Because the rule was already true.
Tricky, huh?
I have a demo somewhere that resolves this. I'll try to find it for you. I think the method I used was to always reset the attribute value to something other than the desired range. For example, you could set it to 0 or to -99 or whatever using a timer... something like this:
Timer every 3 seconds
Change attribute game.obstacleNumber to random(1,3)
Timer after 0.1 seconds
Change attribute game.obstacleNumber to 0
That second timer should give the following rules a chance to spawn actors before the value is reset to 0.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
metalasus and webster, i have a template for an endless runner i got for free from a third party site a while ago that is a good resource to learn from (used it to develop the the chilli run on taco bob). if you guys want to message me your email i can provide to you so you can learn from it too. there were also a few tute videos on youtube that are good to learn from. between those you should be able to suss out how it works.
Thanks tiatang for the advice, but the problem seems to be that it never spawns obstacles after the first one, even with your proposed change. Not sure what's happening there.
Thanks everyone! I found the problem. Apparently, I had typed the word 'random' when I needed to select the attribute function "random". A bit dumb, but now it all works just fine.
That is strange. Are you on Mac?
I always type out my functions.. unless you mean you didn't use the Expression Editor?
Either all, great to here this has been resolved.
GSLearn.com | Templates | Free Demos | Udemy Course
Hmm, yeah, on a Mac you would type the word random into the expression editor.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User