edited February 2023 in ORK Scripting
Hello, I'm using a script for a custom Node in my schematics. This script wasn't written by me, so many thanks to the original author, Tikal!

If you are unfamiliar with how this looks like, it is a very common (if not standard) visual/experiential thing in fighting games and some action games. If you've played a fighting game, you know what I'm talking about. Here is it in action;

image
image
image

It is important to note that during a Hit Stop (this is especially noticeable in 3D games), as you can see, the when people get hit, the screen doesn't pause (sometimes the screen even shakes!), but the characters pause (they pause but their animation doesn't strictly freeze, note in the above gif how Kolin's hair still bounces as she connects hits.)

However instead what's happening in my script below is that when a hit connects, the entire game state freezes.

image

I'm guessing it has to do with this;

Time.timeScale

Which is not what I'm looking for; as mentioned above. However I should mention that the script otherwise doesn't have any issues, so I don't need bugfixing perse, just a change in effect.

Can someone take a look at the script to see what I need to replace it with to get the effect I need? To reiterate, the script is mostly done and works to my liking except for that one effect, which would be fine if that was what I'm going for; so no bugfixes needed. I just want to stop (but not freeze) the animations of the affected models for an arbitrary amount of time I can set.
Thank you!

using GamingIsLove.Makinom;
using Unity.VisualScripting;
using GamingIsLove.Makinom.Schematics;
using GamingIsLove.Makinom.Schematics.Nodes;
using UnityEngine;

namespace _GAME._CUSTOM_ASSETS.ORK.Nodes
{
// The 'EditorHelp' attribute manages the name and description of the node.
[EditorHelp("HitStop Effect", "This node causes a hitstop effect for a specified duration.", "")]
// The 'NodeInfo' attribute manages in which section the node can be found in the add node selection.
[NodeInfo("Combat/Hit Effects")]
public class HitstopNode : BaseSchematicNode
{
// Declare node properties
[Tooltip("The duration of the hitstop effect in seconds.")]
public float Duration;
[Tooltip("The timescale to set after the hitstop effect ends.")]
public float TimeScale;

public HitstopNode()
{
Duration = 0.05f;
TimeScale = 1f;
}

// Execute node
public override void Execute(Schematic schematic)
{
// Pause game
Time.timeScale = 0f;

// Wait for duration
float pauseEndTime = Time.realtimeSinceStartup + Duration;
while (Time.realtimeSinceStartup < pauseEndTime)
{
schematic.Yield();
}

// Unpause game
Time.timeScale = TimeScale;

// Tell schematic what to do next
schematic.NodeFinished(this.next);
}

// Node details
public override string GetNodeDetails()
{
return "This node causes a hitstop effect for a specified duration.";
}

// Node color
public override Color EditorColor
{
get { return Color.red; }
}
}
}

Post edited by FeldFour on
  • edited February 2023
    Without re-designing everything to be a state machine and take into account when and what specific things paused, you can use 2 Animator Speed Nodes, setting the speed to 0 (one for Machine Object, one for Starting Object), followed by a wait node for however long you want the hitstop, and then repeat the speed nodes setting them back to 1.

    This will pause your animations while everything else continues to run at their normal time rate. The first SF example likely uses separate animations for the hair itself, and/or runtime deformation like is done with cloth, and this solution would still allow those to keep moving as well. Granted that's just a guess because of the clipping through the body which happens more often with these two methods than if the hair was animated with the movement.
    Post edited by Acissathar on
  • edited February 2023
    Yeah - setting the time scale to 0 will stop everything (e.g. what happens on freeze pause in ORK/Makinom). If you set it to a value between 0 and 1 (e.g. 0.1) you'll only slow it down instead.

    As @Acissathar said, setting animator speeds is a way to only slow/halt animations instead of everything.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.