Help with some logic issues (it seems to be out of my league!)

scitunesscitunes Member, Sous Chef Posts: 4,047
edited November -1 in Working with GS (Mac)
I am trying to make a game with similar physics to angry birds (with a major twist!)

I've got the sling shot down perfectly (well as good as it needs to be), but I want to have the little smoke puffs that spawn as you fly through the air. That is easy to do of course, but what I can't figure out is how to get it so it only shows the last set of smoke puffs each time. This is really important because it shows the trajectory from the previous shot so you can make adjustments to the next shot. But if the smoke puffs from all previous shots remain in the scene it gets really cluttered and hard to figure out which shot went with which puffs.

Any ideas how to set it up so that only the last set of smoke puffs are visible? Modulus or something?

Thanks!

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Thanks. I was thinking that I could use modulus to cycle between two values. Then have the cycle triggered when the projectile lands. then in the trajectory markers have a rule that destroys them on every other value in the cycle. I may have to have two different marker actors that are told to spawn and destroy oppositely.

    So
    when attribute = 1
    spawn marker1
    destroy marker2

    When attribute = 2
    spawn marker2
    destroy marker1

    something like that!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Well, after a couple of hours messing around with a system based on modulus I have given up (for now). T, I hope you have better luck!

    FMG, you lurking around here anywhere? Could use your math brain right about now!
  • PhoticsPhotics Member Posts: 4,172
    Are you using particles?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    no. Have you played angry birds? The idea is that I have an actor that is shot by a sling shot and as it flies through the air it leaves a trail behind of spawned dots. I want the LAST trail to always show, but ONLY the last trail - not the trails from before. If I just leave a bunch of spawned dots it gets too messy looking.
  • PhoticsPhotics Member Posts: 4,172
    I haven't played it, but I'm imagining what you could do... you want to spawn a trail of dots... so why not associate the dots with an attribute. When the bird gets hit, it could trigger the old dots to be destroyed... use a timer to reset the attribute... then spawn new dots with the movement of the actor.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Got it!

    Here's the basics.

    Create an integer attribute (game.modulusthingy) set it to 0

    Decide when the attribute will change (for me it is when the sling shot is fired)
    so in the projectile I have a rule that says

    When touch is released
    change game.modulusthingy to (game.modulusthingy+1)%3 (This will cause game.modulusthingy to cycle through 0, 1, 2

    Then I created three dot actors dot0 dot1 dot2

    I have rules in the projectile that say when game.modulusthingy=0 spawn dot0, when game.modulusthingy=1 spawn dot1 when game.modulusthingy=2 spawn dot2

    Then in dot0 I have a rule that says when game.modulusthingy=1 destroy
    In dot1 I have a rule that says when game.modulusthingy=2 destroy
    In dot2 I have a rule that says when game.modulusthingy=0 destroy

    You can put a timer around the destroy. I actually put a timer around the destroy and used interpolate to fade out the alpha before destroying. Haven't tried this on a device as this project will be for web only but putting timers in a bunch of spawned dots could cause memory problems so you may want to skip that.
Sign In or Register to comment.