Best method of doing HitStop - semi-SOLVED

Drell

Member
Hello all. I'm currently working on a 2D fighter titled Evolver (see our progress/work here), and I've just finished porting the multiplayer Versus from GM8 to GM:S. I've got everything working and now I'm adding finer details like hitStop. If you don't know, hitStop is a feature of most fighting games that freezes the game for an extremely short amount of time to add intensity and clarify hit collisions. In GM8, I simply used the sleep function which worked incredibly well. As you probably know, GM:S has truncated sleep. I've read several good arguments about stopping the instances themselves versus having all instances deactivate. Does anyone have any suggestions on the best method of doing hitStop? Does anyone know how the sleep function worked before and how it could maybe be programmed as a script/function in GM:S to be effectively the same? All help appreciated :D Thanks!

Here's some gifs of our game in it's current preAlpha stage:

And here's a gif of the survival mode before I started porting it to GM:S

 
R

Robert

Guest
Yes I know what your talking about, I actually just recently added something similar to my game. So, it kind of depends on what you want to do exactly, in my case I am not totally pausing things but slowing them down. If you wanted to pause things then you would need to go into all of your code, everywhere, and anything that is performing any kind of movement or change over time you will want to throw a condition around it that says something like if(hitstop != true) then move
 

Freddy Jones

Your Main Detective
This method should be pretty convenient.

In the end step of some object, make sure it's done after all computations, reverse values affected by time by a percentage of your choice.

For example, if you wanted to slow down the effect of speed, you'd go through every applicable instance and interpolate the value from its previous state with its current state. You could do something similarly with image angle, image scales, image index, and it wouldn't require you to change much of if any of your code, without the side effect of a forced frame rate drop.
 

Ralucipe

Member
Probably the simplest thing to do... (not tested, just theory)
I second this solution- putting code in every instance to temporarily stop moving would be a pain to program and debug. Better off significantly reducing the room speed for a couple frames instead to artificially slow it down.
 

Freddy Jones

Your Main Detective
If you wanted to just completely pause it like "sleep" did, your best bet would be exactly what you mentioned.

Deactivate all relative instances and save the graphics state. There's a whole bunch of topics over on 'pausing' on here you can find.
 

Mick

Member
Slowing down or pausing the hole room seems like the easiest solution, but this will the slow down everything on screen. The "proper" technique is for hitstop to only affect the two objects involved in combat right? I started looking for a solution to my game as well, but there's a two player co-op mode in it and pausing the whole game would be weird for the other player.

It shouldn't be too hard to "freeze" the logic for the player and enemy involved, saving the current speed, direction, image_speed etc. Then either set new speeds to a fraction of the old ones or to zero for a few steps. When hitstop ends, reset the speeds to what they were and enable the logic.
 

Drell

Member
Sorry for late post; I'm not getting notifications on this post, perhaps it's not set by default. Anyhoo, I tried a few solutions, so I'll detail how they went and where I've ended up.

The first thing I tried was to create a function called "sleep(timeInSeconds);" that created a background from the application surface and then drew it for whatever time in real seconds was argument0. However, the time it took to create and store the backgrounds affected the hitStop time pretty drastically (about 500ms) and I scrapped the function.

Instead, I created a int variable called "global.hitStop" that works like an alarm by setting the image_speed to 0 and exiting the step event before the rest of the code can be executed. This works pretty well for stopping the players, and because each hit has a "hitZone" which is set to a string, it's easy to make certain attacks (e.g multiHit attacks and certain projectiles) avoid hitStop where it may look unnatural. This only works because to some degree, the player is entirely controlled and or queued in the step event, so exiting the event after setting the image speed to 0 effectively freezes the player.

@WitchMaster There is a coop-survival mode in Evolver where I can set a maximum for the hitStop so it can freeze slightly longer if multiple hitStops occur without slowing to a ridiculous pace. Or, vis versa, and I can completely remove the hitStop. My onedrive didn't sync correctly from my work PC, so I don't have the game after the changes I made. I'll post a gif in the morning (eastern time) if I remember.
 

Drell

Member


Here's the GIF with screenShake and hitStop; I may increase the hitStop by a few ms, but it works which is what's important.
 
Top