Показать сообщение отдельно
Старый 22.11.2013, 09:10   #2
Andvrok
Бывалый
 
Регистрация: 26.07.2009
Сообщений: 785
Написано 362 полезных сообщений
(для 995 пользователей)
Ответ: Получить "реальный" DeltaTime

Вот нашёл на бурговском сайте, попробуй.

The private timescale multiplier in it's simple form will not work with a timescale of zero. This is what I did to have a logical Timer that can be paused while the rest of the game continues on it's usual pace:

using UnityEngine;
using System.Collections;
 
//=========================================================================
// Class: TimeKeeper
// Mirrors Unity's Time.time, allowing the game to be logically paused
// while the animations, UI, and other Time.time dependant tasks keep running at the usual pace.
// TimeKeeper can be paused by the game when timestamp is set to 0,
// or by the user pressing the Pause/Break key.
//=========================================================================
public class TimeKeeper MonoBehaviour {
 
    
// Variable: time
    // Access TimeKeeper.time to keep track of time with a different timescale then Time.time (read-only)
    
public static float time {
       
get { return instance.mTime; }
    }
 
    
// Variable: timescale
    // Current timescale of the TimeKeeper.
    
public static float timescale {
       
get { return instance.mPaused instance.mTimescale; }
       
set instance.mTimescale value; }
    }
 
    
//=========================================================================
    
private static TimeKeeper instance;
 
    private 
float mTime 0.0f;
    private 
float mTimescale 1.0f;
    private 
float mLastTimestamp 0.0f;
    private 
bool  mPaused false;
 
    
//=========================================================================
    
void Start ()
    {
       if (
instance)
         
Debug.LogError("Singleton violated (ooh!)");
       
instance this;
       
instance.mLastTimestamp Time.realtimeSinceStartup;
    }
 
    
//=========================================================================
    
void Update ()
    {
       if (
Input.GetKeyDown(KeyCode.Pause))
         
this.mPaused = !this.mPaused;
 
       
float realDelta     Time.realtimeSinceStartup this.mLastTimestamp;
       
this.mLastTimestamp Time.realtimeSinceStartup;
       
this.mTime += realDelta timescale;
    }

I did it with my needs in mind - you could 'un-Singletonize' that and have an arbitrary number of TimeKeepers and attach them to your objects.

А вообще можно пробовать для нужных объектов просто вырубать "движущие" скрипты, как Rigidbody для остановки физики или ParticleEmitter для остановки частиц.
(Offline)
 
Ответить с цитированием