Logic question for a timer

Hello all I need help figuring out some code. I want to create a block of code that recognizes when my actor is standing still for a period of 30 seconds. For example I want my actor to destroy if he stands still for 30 seconds.

This is what i have so far a rule when all att. self.time = 30
slef.motion.linearvelocity.x = 0
self.motion.linearvelocity.y = 0
Destroy.

it kinda works, but once i move my actor around the scene for a little bit and keep him still it doesn't execute the block of code anymore.
any suggestions? thank you

Comments

  • RabidParrotRabidParrot Formally RabidParrot. Member Posts: 956

    Change the rules to a less than equation. If linear velocity x < 3, "3" representing any number, after 30 seconds destroy.

    Because your telling the actor to destroy only when the velocity is exactly 0. If the player wiggles the actor around the linear velocity will be more than 0 and not equal to it.

  • Hipster_Owl_StudiosHipster_Owl_Studios Member, PRO Posts: 214

    thanks!

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2015

    @Hipster_Owl_Studios said:
    thanks!

    Your code won't tell you whether an actor has remained still for 30 seconds, it will just tell you whether it is still at 30 seconds, it could be flying all around the screen for 29 seconds and then briefly pause for just a second and your rule will still fire.

  • Hipster_Owl_StudiosHipster_Owl_Studios Member, PRO Posts: 214

    @Socks thanks for the input after testing some more i found out your right it still doesn't work. any ideas?

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2015

    ...

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2015

    ...

Sign In or Register to comment.