I am creating a game where multiple players will be fighting multiple enemies at once. I am trying to implement a “hit pause” where when an attack connects, the attacker and the attacked pause for a brief moment. The problem is, I know I can affect the time scale to achieve this effect, but it will pause the game for everyone rather than those actually involved in the combat. This is not optimal as it will make timing intensive moments difficult if the game is constantly pausing for you alone.
How can I use time scale on just one person, or how can I emulate the effect this effect to where it doesn’t affect everyone?
timeScale is a “global” parameter, and you cannot modify it for a subset of your characters. But you can “freeze” the position/rotation of the characters involved and, of course, disable all the scripts responsible of damage assignment, collisions consequences, etc…
When the pause button is hit again, enable those scripts again.
You could also change the material (passing through a “transparency” one, as an example) of those characters, to visualize them “different” from the others, since they’re not in the action.
Eh. I figured I couldn’t single it out for one character. Oh well.
How would you recommend I go about freezing the position of the characters? The way I tried it was to, first, pause the character’s animation, store the character’s velocity in appropriate variables, turn off gravity, and attempt to freeze the velocity during the pause. After the pause was supposed to be over, I unpause the animation, set the character’s velocity to whatever was stored, and turn gravity back on. The problem with this, is that all my characters are using rigidbodies and I’m finding that the exit velocity is not accurate.
Actually, I’m finding that using rigidbody physics isn’t quite accurate for a fighting type game. Perhaps I’m doing something wrong here as well, but I don’t really feel like I am. Should I be using character controllers for something like this? Technically I don’t actually need physics.