Pretty clear video! One of the hit stops that I really like is when you do a parry in Ultrakill, that little stop letting you see and sorta feel the punch is great
As someone who has never even heard of Coroutines, I was able to follow along and pretend like I understood what was happening. I'm sure as I do it more I'll get more familiar with the logic behind everything, but nevertheless, this was an amazing tutorial that was easy to follow and impliment into my own game. Tysm!
FYI: If you destroy the object that calls the pause (ie: a dying unit start a coroutine to pause the game) timescale won't return to normal after that object is destroyed. So only call this from objects which persist.
Just for anyone implementing this, it's better practice to create a singleton/static instance for your manager classes, rather than calling FindObjectOfType. Having static references will have less overhead than getting the Unity engine to scan through objects to check their types, and will significantly increase performance in areas where you try to access said objects frequently.
You can make hit stop coroutine public and inside WaitForSpawn do yield return HitStopCoroutine(.1f). When you do this WaitSorSpawn coroutine will wait untile the HitStopCoroutine end it execution. In my opinion It's more readable that way.
That's one way to do it. I hadn't actually considered doing it this way so it's cool to see a different take. Which one is more readable is definitely up to interpretation. In this example the crate is destroyed in one shot, but in a real use-case enemies would often take more than one hit, and you would still need to initiate hit-stop then. This is also designed to make it so that you can initiate hit-stop from anywhere and not really have to worry about it. The WaitForSpawn bit was included more to show the kinds of things you want to take into consideration when implementing hit-stop. You definitely know what you're doing, so whatever works best for your game is the right way to go :)
As I am using timeScale also for pausing I have run into an issue where pausing right after hitting an enemy ends up in a really bad scenario (game is paused but player can move). Any ideas how to go around it?
My solution is generally to create something that automatically manages this for me. It could be as simple as having the hit stop coroutine check a static *paused* bool from another object, or as complex as having a class just to manage how other classes can access time scale (if you have a lot of time stopping and slow motion effects). Someone else in these comments mentioned using animations instead of time scale to creat a similar effect in multiplayer (where time-scale changes are ill-advised) so that might work, but it's more of a work around at that point.
Yes, this approach is not recommended for multiplayer games. You generally should not manipulate time scale in multiplayer games. Just like how a start menu shouldn't pause the game in multiplayer but normally does in single player. I can't think of any multiplayer games that use hit stop (maybe Monster Hunter does? I haven't played it).
This is what I’ve needed for the past 2 hours, thanks!
Pretty clear video! One of the hit stops that I really like is when you do a parry in Ultrakill, that little stop letting you see and sorta feel the punch is great
Simple,fast, Informative, well spoken and pretty helpful overall tutorial, thank you very much sir!
As someone who has never even heard of Coroutines, I was able to follow along and pretend like I understood what was happening. I'm sure as I do it more I'll get more familiar with the logic behind everything, but nevertheless, this was an amazing tutorial that was easy to follow and impliment into my own game. Tysm!
I really like the hit stop in smash bros. Just the right amount for that game.
Simple clean and fast. THank you for sharing the source code as well!
I imagine there is a reason, but your code videoa are incredible, I would love to see you continue.
FYI: If you destroy the object that calls the pause (ie: a dying unit start a coroutine to pause the game) timescale won't return to normal after that object is destroyed. So only call this from objects which persist.
Or just set the timescale back to 1.0x right before the Destroy statement
best solution is, keep pauser object in hierarchy seperate, undestroyable and call it when you need, not in enemy object
Just for anyone implementing this, it's better practice to create a singleton/static instance for your manager classes, rather than calling FindObjectOfType. Having static references will have less overhead than getting the Unity engine to scan through objects to check their types, and will significantly increase performance in areas where you try to access said objects frequently.
Came looking for this comment!
Thank you for the vid. High quality content, I think your channel is gonna blow up soon.
Thank you!
I hope it does aha sharing the video helps with that!
That is good , it might be applied to fighting game with this tip
imagine finding an amazing channel and than finding out it's inactive
College is tough 🙃
I really like making these though! Possibly more in the future
YOURE IN COLLEGE!? This content is way too good man props to you for squeezing all of this into ur schedule
Love every your unity related video, but I see your latest video is 2 years ago. I hope you can active post tutorial again.
Interesting stuff! Thanks!
You can make hit stop coroutine public and inside WaitForSpawn do yield return HitStopCoroutine(.1f). When you do this WaitSorSpawn coroutine will wait untile the HitStopCoroutine end it execution. In my opinion It's more readable that way.
That's one way to do it. I hadn't actually considered doing it this way so it's cool to see a different take. Which one is more readable is definitely up to interpretation. In this example the crate is destroyed in one shot, but in a real use-case enemies would often take more than one hit, and you would still need to initiate hit-stop then. This is also designed to make it so that you can initiate hit-stop from anywhere and not really have to worry about it. The WaitForSpawn bit was included more to show the kinds of things you want to take into consideration when implementing hit-stop.
You definitely know what you're doing, so whatever works best for your game is the right way to go :)
@sixdot. How about a video on effects like the trail and smoke effect like in the start of this video. Would be awesome!!!
hit stop is best used in some sort of melee combat. for example fighting games in general have it and without it, they would feel very awkward.
Great video, thanks
Why didn't you use "Invoke" ?? Less code , safe effectiveness
Using FindGameObjectWithType isn't a good idea - its probably best to use a singleton for the hitstop
As I am using timeScale also for pausing I have run into an issue where pausing right after hitting an enemy ends up in a really bad scenario (game is paused but player can move).
Any ideas how to go around it?
My solution is generally to create something that automatically manages this for me. It could be as simple as having the hit stop coroutine check a static *paused* bool from another object, or as complex as having a class just to manage how other classes can access time scale (if you have a lot of time stopping and slow motion effects).
Someone else in these comments mentioned using animations instead of time scale to creat a similar effect in multiplayer (where time-scale changes are ill-advised) so that might work, but it's more of a work around at that point.
A simple check if(paused && timeScale != pausedTimeScale) {timeScale = pausedTimeScale} on update will solve that and will run only once.
will this work in 3d as well?
Great video
i dont think is a good idea, Time scale is a global variable,its can‘t be use in Multiplayer game,like monster hunter world
Yes, this approach is not recommended for multiplayer games. You generally should not manipulate time scale in multiplayer games. Just like how a start menu shouldn't pause the game in multiplayer but normally does in single player.
I can't think of any multiplayer games that use hit stop (maybe Monster Hunter does? I haven't played it).
@@NebulaCoding i think may be use
animator.speed = 0;
rigibody.bodyType = RigidbodyType.Static;
can achieve that
@@NebulaCoding Pretty sure most fighting games have hitstop.