A timer for my actors question

DrGlickertDrGlickert Member Posts: 1,135
edited November -1 in Working with GS (Mac)
Here's what I'm struggling with right this second;

I want a ball to continuously fly around the screen, however, only if it's hitting certain actors. So if it doesn't hit an actor then it should only last on screen for 5 seconds.

So if this ball is flying around and it hits another actor, how can I reset the timer before the ball get's destroyed?

This may be a simpler fix than I'm making it out to be...

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    im not sure im understanding exactly what you want to do with it, so i cant really tell you if theres a better way. I can answer your question for you though.

    Have a attribute called balldestroy set to 0, and a boolean called ballinplay or whatever set to false.

    In the ball have a rule when the ball enters screen (or whenever you want the 5 second countdown to begin)change ballinplay to true.

    Have another rule when ballinplay is true, change attribute balldestroy to balldestroy+1.

    hen have another rule when the ball collides with whatever you want to reset the timer, change attribute ball destroy to 0. (so it will reset the timer but keep countin)

    Have another rule when ball destroy =5 ,destroy ball, and change attribute balldestroy to 0 and change ballinplay to false.

    Then whenever you introduce a new ball into your scene change ball in play to true to start your timer up again.
  • DrGlickertDrGlickert Member Posts: 1,135
    I want to put a timer on the balls that are flying around. As long as they are actively engaged in hitting blocks of their color then I want the balls to stay in the scene. But if they aren't then I want them to be destroyed. I'll try your way and see if that works for me.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    DrGlickert said:
    I want to put a timer on the balls that are flying around. As long as they are actively engaged in hitting blocks of their color then I want the balls to stay in the scene. But if they aren't then I want them to be destroyed. I'll try your way and see if that works for me.

    ahh okay. The way i told you should work perfect for you then
  • DrGlickertDrGlickert Member Posts: 1,135
    I guess my question is more about how to continuously update a timer.

    I don't want a static number in the timer, I want the timer to be able to increase with the ball's activity in the scene.

    So if the ball's "doin' work" and "being productive" by hitting bricks, then I want the ball to stay. If it's not, then I want the ball to be destroyed.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    DrGlickert said:
    I guess my question is more about how to continuously update a timer.

    I don't want a static number in the timer, I want the timer to be able to increase with the ball's activity in the scene.

    So if the ball's "doin' work" and "being productive" by hitting bricks, then I want the ball to stay. If it's not, then I want the ball to be destroyed.

    Yeah thats exactly what the way i told you will do. If it doesnt hit anything for 5 seconds then it gets destroyed. If you want a longer time, just swap that number out. But as long as it stays hittin bricks it wont get destroyed. Trust me just try it out real quick lol
  • DrGlickertDrGlickert Member Posts: 1,135
    Hmm, I don't think it'll work. The player can shoot multiple balls at one time. I'll think on this one for a bit and see what I come up with...
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    if theres multiple balls just make all those attribute self attributes and not game or scene, then they wont be tied to each other
  • hackmodfordhackmodford Member Posts: 48
    This should work if you do what JohnPaiomitis said and make the timer attribute a self attribute...

    That way each individual instance of the ball will have it's own timer.
Sign In or Register to comment.