"Wait" and timescale issues

0 favourites
  • 4 posts
From the Asset Store
Wind effect
$2.49 USD
Animated wind effect for objects, grass, trees, etc.
  • I'm trying to create an enemy behavior where the enemy will freeze momentarily if they are hit by one of the player's bullets.

    Though setting the enemy's "timescale" to 0 works to some degree, I have run into a major unforseen issue due to how my enemy is set up. The enemy's behavior involves waiting for a couple of seconds, firing a bullet, then firing a second bullet, and then restarting the process. Simple enough. To accomplish this, I'm using the System command "wait" to determine the amount of time between enemy actions. (seen below)

    <img src="http://i1306.photobucket.com/albums/s571/Matt_Dabrowski/enemy_zpsfe1d9b64.png" border="0" />

    The problem is this: Setting the enemy's timescale to 0 does not pause these specific System Waits. So if there is a wait of 2 seconds and I shoot the enemy at 0.5 seconds, this Wait will continue to count even though the enemy is supposed to be frozen. So once the enemy is unfrozen, their next action will occur immediately instead of 1.5 seconds later.

    I'm going to attempt my own solutions and I'll post here if I come up with something that works really well. It may just involve completely changing the way I write enemy behaviors (maybe it's not a good idea to be using Waits for this sort of thing). But I'm curious as to how other people have dealt with these sorts of timing issues.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • A good way is use delta time to set your "waits" and "stuns"

    set your enemy/enemies an instance variable,lets call it "pause"

    enemy variable "pause" equal to 0......do enemy stuff (normal behaviour so have it set at that to begin)(start movement)

    ok now if your enemy is hit

    enemy on collision with player shot....set variable "pause" to 1(stop movement)

    enemy fires for first time>...set variable "pause" to 3(stop movement)

    enemy "pause" equals 2>.....fire second shot(stop movement)

    now this is the waiting bit

    eneny variable pause is greater than 0...enemy subtract 0.5*dt from "pause"

    because after firing it is set to 3 it will cout down creating a pause then hit 2 and fire again

    using bullet behaviour just set the bullet speed to 0 to stop and back to default when you want movement again...

    You can play about with the 0.5*dt and numbers to set your wait time.

    hope that helps...ps: using wait is not the best way as i think you realised....

  • That was a really good idea. I changed my implementation to use this method.. works like a charm. Many thanks.

  • Glad you got it working,happy to help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)