Spawn Actors based on an Actor's Speed as Game Increases
After doing many searches to find a solution to my problem I could find nothing. So here I am trying to get my problem solved once and for all.
My problem:
My Actor1 gets spawned every 1.5 seconds.
Actor1 is traveling at a speed of 67 across the screen.
Every 8 seconds, Actor1 increases speed by 8 (After 8 seconds: 67+8=Speed of 75)
Although this is creating large gaps between each spawned Actor1.
I want the gaps to be the same space away from each other as if the actor was being spawned every 1.5secs with a speed of 67.
The only difference is my Actor1 speed is increased and the gaps between each Actor1 is very large.
Example: this symbol @=Actor1: Speed of 67: @---@---@ Speed of 75: @------@------@ and so on of increments of 8
That is an example of what it looks like.
Any help on how to fix this is greatly appreciated. If you need more clarification of my problem I will be happy to explain it more. Thanks and have a great day,
~G4L
Comments
You'd have to adjust the spawn frequency based on the actor's speed.
This question just came up recently and I feel like I made a demo for it but I can't seem to find it. If I do, or if I find the original thread, I'll post it here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You would need to decrease the time it takes to spawn for the gaps to be closer.
Speed = distance/time.
if you increase the speed, it will go further in a shorter amount of time, but if you are spawning more often, this can compensate for the increase of speed because you are manipulating time.
essentially you'd want to set up an attribute to control this, so something like
so you can tie the increase of speed to the decrease in time to spawn.
You could also do this with an algorithm. I'm not sure of the exact values but something like
edit: @tatiang beat me to it!
Follow us: Twitter - Website
@AlchimiaStudios No no, my post was a generic response whereas yours is much more helpful.
The only note I'd make is that you can't use an expression or attribute within a Timer behavior. The Timer will calculate the initial value and use that every time it cycles. For that, you'd use a custom interval timer.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks for your helpful responses! @tatiang and @AlchimiaStudios
@tatiang When I tried using the custom interval timer, all it did was make my screen shake red(the background). When I went to preview it, the screen just blurred with the background and my game froze.
Any help to solve this is appreciated.~G4L
Knowing that my demo works and yet hearing that your attempt at using it caused your screen to shake red and blur with the background and freeze makes me wonder whether you modified it and it's not working because of some change you made or if you just previewed the demo I made after downloading it and it didn't work at all.
You could either post a link to a hosted screenshot of your rule(s) or you could post a link to the project file (.zip it first) and I'll see if I can figure out what's wrong.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
prntscr.com/5tl6c2
prntscr.com/5tl6v5
@tatiang This is what my custom timer looks like. The top pic is the top part and the bottom pic is the bottom part of the rule in the timer.
Any help is appreciated and thanks for all your help so far!
~G4L
In your first iteration, you are changing self.Name (the name of the actor) to the new duration instead of changing self.duration.
In your rule, you are checking to see if game.Time ≥ self.timeStamp instead of checking to see if game.Time ≥ self.timeStamp+self.duration. The idea is that the "time stamp" records what time the loop/timer starts. The rule then checks to see if the running time, game.Time is at least equal to the time stamp plus the duration you've set.
Finally, you're setting self.timeStamp to random(3,7) instead of to game.Time. If you do that, then the rule stops working after a few seconds; imagine if game.Time is 30 after thirty seconds... the rule is going to check to see if at least 3 to 7 seconds plus the duration have elapsed. But you're way beyond that so it won't ever trigger again.
By the way, I didn't look at your screenshots and troubleshoot the logic... I just compared your screenshots to my demo:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Thank for you for your help so far, although I am still running into problems. After copying your demo line for line, I am still running into the same problem my screen always looks like this:
prntscr.com/5totnl
Although it just looks like a scene, this scene flickers back and forth between this scene and my title scene. In case you're wondering what the blue thing is, that is my main actor (not the thing I want to spawn). The red is my background.
The only different thing I have done with your demo is replace the debugger statement with my Spawn actor behavior. Sorry for this continuing problem and as always, your help is greatly appreciated.
~G4L
Bump @tatiang
Thanks,
~G4L
A screenshot of the result isn't helpful for me to then know what went wrong or what you need to change. Can you send me a private message (PM) with a link to download your project file (please .zip it first)? Some things are quicker with the actual file rather than asking you to post your screenshots again and guessing about how you have it all set up as far as scene changes, etc.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi @Games4life I would make a general recommendation, whenever you find a "bug", tries to find out who is causing it, leaving everything else aside. For example you can go deleting objects, to find the one that causes it ... once I found the object, you can do the same in this, erasing contrains and other items inside it, until you can isolate the cause of the problem.
Following this method, 99% of the time, you'll see that the problem is on your side, either a logic error or typo and so.
good luck
Thanks I'll try that! Thanks for your help! Same with you @ tatiang!
~G4L