how do i slow down time without slowing down the player
TL;DR [START]
as i want to achieve a superman like effect of super-speed, but not the half assed kind you see in a lot of video games where you move super-fast and nothing is slowed down, while great for large distances (as who wants to spend ages running 100 miles in slow motion), terrible for precision, eg navigating a maze or house or car crash or pedestrians, a small distance, and so on, at super-speed
as i believe Spider-Man 2 (2004) (PS2) was the first game to implement this correctly with its Spider-Reflexes mode (carried over to Spider-Man 3 and renamed 'Reflex Time') that also do this correctly (and perfectly as there is basically no undesired effects via transitioning to and from reflex mode)
and after playing Spider-Man 3 (cus Spider-Man 2 is only available on ps2 and i dont own a ps2 anymore, and the pc version of it is an entirely different Spider-Man game, literally) with a trainer (for infinite health and infinite reflex time),
Reflex Time is effectively a complete working (low speed) super-speed implementation, which is exactly what i am trying to mimic, as in slow motion you notice virtually no change to your players speed and animation speed and momentum, even while swinging, falling, swimming, jumping, climbing, wall running, everything you can think of, i will link video's to this in action once they are uploaded in about 2 hours (as time remaining till the upload is complete is about 2 hours)
TL;DR [END]
as i tried to implement my own version but i encountered the following bugs
when jumping then slowing down time, my character jumps at a lower height, due to the jumpforce not scaling with timescale
when jumping then speeding up time my character jumps WAY higher than normal
when falling and slowing down time my character slows down then speeds back up to normal
when falling and speeding up time my character falls WAY faster than it normally should
when moving and speeding up time my character zooms forward for a bit then moves normally
when slowing down time beyond 0.005, eg 0.004, the movement code that balances this becomes unreliable as the player will move faster than they are supposed to, which should not happen
these bugs should not be happening yet they are and i do not know how i would fix them
i tried using Time.FixedDeltaTime and Time.fixedTime but
although the player moves and transitions from normal to slow mo and vice versa exactly how i want it to (basically not noticeable, as if nothing has happened when actually everything is slowed down)
if i put an explosion next to a cube while slowed down the cube physics appear to be lagging a lot, like 0.5 fps which is bad, i need the physics to be real-time but still slowed down with the player
a friend suggested i use a tween effect but i have no experience with those and i cant find any youtube videos about them for use with slow motion
so i am starting from scratch starting with a simple jump then progress through implementing the movement
this is my new script
using System;
using System.Collections;
using System.Collections.Generic;
using Unity;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class newjump : MonoBehaviour {
Rigidbody R;
public float force = 375f;
public bool grounded = false;
public float ColliderEdge;
CharacterController C;
// Use this for initialization
void Start () {
ColliderEdge = GetColliderEdge();
R = GetComponent<Rigidbody>();
C = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
grounded = IsGrounded();
if (grounded) if (Input.GetButton("Jump")) R.AddForce(Vector3.up * force, ForceMode.Impulse);
printfTools.Tools.fprintf(Debug.Log, "Physics.Raycast(transform.position, hitInfo, ColliderEdge) = %s", grounded?"true":"false");
}
float GetColliderEdge()
{
if (GetComponent<Collider>().GetType() == typeof(SphereCollider))
{
return GetComponent<SphereCollider>().radius;
}
return 0f;
}
bool IsGrounded()
{
RaycastHit hitInfo;
return Physics.Raycast(transform.position, -Vector3.up, out hitInfo, ColliderEdge);
}
}
how would i get the jump to... not slow down when the Time.TimeScale changes but in a way that does not introduce any of the bugs previously mentioned