Hi all,
I’m making a game where the object got knocked off by the player will be sent into a space where time is slower than usual.
I’m using the physic engine on the object falling only and I’m controlling everything else with my own script.
Using Time.timeScale will create more work for me and changing the gravity just make everything less believable.
Is there a way to change the time for the physic engine only?
Cheers!
Set the timeScale to whatever you want for the physics. And use the unscaledTime as the time that doesn’t scale down (anything that moves normal when the physics is slowed).
Personally I created my own ITimeSupplier interface and various timesupliers including a CustomTimeSupplier to facilitate this in an OOP manner:
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using com.spacepuppy.Utils;
namespace com.spacepuppy
{
/// <summary>
/// A static entry point to the various ITimeSuppliers in existance. An ITimeSupplier gives object identity
/// to the varous kinds of time out there: normal (UnityEngine.Time.time), real (UnityEngine.Time.unscaledTime),
/// smooth (Time.smoothDeltaTime), custom (no unity parrallel).
///
/// With the objects in hand you can than swap out what time is used when updating objects.
///
/// For example the com.spacepuppy.Tween namespace containers tweeners that can update on any of the existing
/// times in unity. These objects can be passed in to allow updating at any one of those times. Lets say for
/// instance you've set the time scale of Normal time to 0 (to pause the game), but you still need the menu to
/// tween and update appropriately. Well, you'd use the 'RealTime' or a 'Custom' time object to update the
This file has been truncated. show original