Post by Aaron on Jun 18, 2021 19:46:50 GMT
I tried EvilA's Bullet Time a while back and got a bunch of errors, tried the various fixes, and couldn't get it to work, so I found another way to get basically what I wanted using a bastardized version of a Brackey's Tutorial..
Here goes, and it's really simple too.
Step 1: Add an Empty Game Object to your Shooter Weapon.
(For this example I'm using an M4 Carbine that I've made from cloning Invector's Assault Rifle, and it works on the standard Shooter Invector Weapons.)
Now, Name the Empty Game Object "Time," and attach the "Time Manager" Script.
(Time Manager Script will be Included at the Bottom of this Post)
Step 2: In the vSHOOTERWEAPON Script, click on EVENTS and go to "ON ENABLE AIM" and Insert as "Runtime Only" "TimeManager.DoSlowMotion"
Then go to "ON DISABLE AIM" Insert again as "Runtime Only" "TimeManager.CancelInvoke - DoSlowmotion"
You may have to physically type in "DoSlowmotion" in the allotted slot.
You may have to physically type in "DoSlowmotion" in the allotted slot.
Step 3. Go Shoot Stuff.
The basics are: As you aim your weapon at your target, "On Enable Aim", time will slow down, helping you aim before you begin to shoot, and then ease back into normal time after you've taken a few shots. (Blood splatters in slo-mo are awesome!)
The slowed down Time and Duration of the effect spaces are Public Floats so that you can make your adjustments in the Unity Editor instead of re-writing the script. This way you can make time slow down more or less than the script and make the effect last longer or shorter - It's all up to you!
The reason for the inclusion of the "Cancel Invoke" in the "On Disable Aim" is to prevent the effect from overlapping when switching from one shooter weapon to the next if your "Slow Down Duration" goes on too long.
The reason for the inclusion of the "Cancel Invoke" in the "On Disable Aim" is to prevent the effect from overlapping when switching from one shooter weapon to the next if your "Slow Down Duration" goes on too long.
See in action here:
Time Manager SCRIPT -
___________________
using UnityEngine;
public class TimeManager : MonoBehaviour{
public float slowDownFactor = 0.05f;
public float slowDownDuration = 2f;
void Update()
{
Time.timeScale += (1f / slowDownDuration) * Time.unscaledDeltaTime;
Time.fixedDeltaTime += (0.01f / slowDownDuration) * Time.unscaledDeltaTime;
Time.timeScale = Mathf.Clamp(Time.timeScale, 0f, 1f);
Time.fixedDeltaTime = Mathf.Clamp(Time.fixedDeltaTime, 0f, 0.01f);
}
public void DoSlowMotion()
{
Time.timeScale = slowDownFactor;
Time.fixedDeltaTime = Time.fixedDeltaTime * slowDownFactor;
}
}
_____________
And if anyone has any improvements they can make upon this, by all means, please do and please share your results.