Comments (23)
Took a while, but I finally made some tests.
DOTween works with negative timeScales (meaning it plays backwards instead of forwards), so that part is good. To attach a tween to a Chronos timeline, Lazlo suggested to use an update routine, so this should work:
myTween.OnUpdate(()=> myTween.timeScale = myChronosTimeline.timeScale);
I don't have Chronos, so if some user is interested and can check this out it would be great :)
from dotween.
If you want to make this an extension method and easily use it with Chronos, you could write:
using Chronos;
public static class MyExtensions
{
public static void RegisterTimeline(this Tween tween, Timeline timeline)
{
tween.OnUpdate(()=> tween.timeScale = timeline.timeScale);
}
}
Then, when you need to register it on a tween, simply call:
myTween.RegisterTimeline(myTimeline);
from dotween.
Chronos looks very very nice, but from a quick glance it seems it can't really be setup via code, but only via drag & drop. Am I wrong?
Also, what type of support you had in mind? DOTween already has its own timeScale (both Unity-dependent and Unity-independent), and each tween has a specific additional timeScale you can act upon.
from dotween.
Hi Daniele,
Chronos runs on it's own Global time scale which can be set for specific
enemy types, level areas, GUI, or player. IE time can slow down for enemies
that get hit by a time grenade. It'd be nice to have support for this in
DOTween. I think the easiest way to add support for this would be to allow
the user to pass in a time object. I haven't looked at the Github code,
but maybe I'll do that tonight and let you know.
Thanks for a great control!
On Tue, May 19, 2015 at 3:39 AM, Daniele Giardini [email protected]
wrote:
Chronos looks very very nice, but from a quick glance it seems it can't
really be setup via code, but only via drag & drop. Am I wrong?Also, what type of support you had in mind? DOTween already has its own
timeScale (both Unity-dependent and Unity-independent), and each tween has
a specific additional timeScale you can act upon.β
Reply to this email directly or view it on GitHub
#19 (comment).
from dotween.
Hi!
Did you check how it could be done, by any chance? I know nothing of Chronos right now. Maybe if you could show me how it could be integrated, even with stub code so I can just understand the logic, I might see if it can be done.
Cheers!
from dotween.
Hi Daniele,
Sorry for the delay, I haven't had a chance to implement it yet. I'll let
you know as soon as I do.
-Jon
On Sun, May 24, 2015 at 5:25 AM, Daniele Giardini [email protected]
wrote:
Hi!
Did you check how it could be done, by any chance? I know nothing of
Chronos right now. Maybe if you could show me how it could be integrated,
even with stub code so I can just understand the logic, I might see if it
can be done.Cheers!
β
Reply to this email directly or view it on GitHub
#19 (comment).
from dotween.
Hey, got redirected here from Unity Forum ;) Chronos aside, I would like to be able to provide own timer implementation and inject it to DOTween. I assume DOTween uses Unity's Time class but I want (for example) to be able to pass a timer object associated with specific GameObject. So say transform.DOMoveX(1, 1, _timer) where _timer is abstract thing that DOTween uses to measure elapsed time.
from dotween.
Hey,
I don't know if it can help with what you have in mind, but DOTween has its own timeScale (which is multiplied by Unity's), plus every single tween has a separate one (multiplied by DOTween's timeScale and Unity's).
from dotween.
Since passing of time in custom timer may vary in speed through since tween it might be very difficult to workaround by constantly changing each tween's timeScale (especially if I still want to keep tween's timeScale wrt to its timer). If DOTween had abstracted Timer (with default implementation of Unity's Time) it would be ideal.
from dotween.
Then the static DOTween.timeScale should be good, if I understood correctly :)
from dotween.
Static timeScale should be useful for per GameObject timers running at different speeds and with those speed changing at different rates (non linear ways)? How...?
from dotween.
Please take a look ad Chronos demo video (tho mind that it does not matter that it is Chronos, just that time is controller in various ways):
https://www.youtube.com/watch?v=-zq1OZuGXoc
Now say I want my tweens inside Area Control (1:11 min) to go backward in time (rewind). In such case timer.elapsedTime should produce negative values and tweens should just still scale it by own timeScale. What do you think?
from dotween.
Hey sorry for the late reply. My computer is dying (which happens when you use a 7 years old laptop :P) and I'm kind of stumped while waiting for a new one. I'm writing to Chronos' author in the meantime to see if he has any suggestions. Please ping me back around Thursday, if I still haven't come out with some info.
from dotween.
Chronos author here, hello!
I'll talk with Demigiant in PM to see if we can enable a Chronos integration in DOTween. :)
from dotween.
Fantastic news :)
from dotween.
Thanks for the tip Mr Chronos :)
A note to users: Lazlo's extension method is definitely the way to go, but you'll have to create it yourself in your project. I prefer not to implement it as an official extension method (for now), both because it hides the fact that users wouldn't be able to use OnUpdate for custom methods, and because I would have to add it as an external unpackable file (which would be unpacked by DOTween's Setup in case Chronos is present).
That said, it's not a definitive choice, and I'll ponder more about it. Lazlo, in case I choose to implement it, what file-system way could I use to determine if Chronos is present? Is there some special file which is named ChronosMasterOfTheUniverse or something like that, whose existence I can query to determine Chronos availability?
from dotween.
You should be able to look for Timekeeper.cs
, which is kind of like ChronosMasterOfTheUniverse (maybe I should've chosen that name instead). It's located by default under Chronos/Source/Timekeeper.cs
, but for future-proofing, maybe you shouldn't look for the exact path. I think it's unlikely other projects or plugins would use the Timekeeper name.
That being said, I'm not sure how you can integrate it even with that check. The code wouldn't compile without Chronos because of the Timeline reference, and I can't provide a preprocessor check (e.g. #define CHRONOS
, because that's a file-scope only, or /define CHRONOS
, because Unity projects are auto-generated). If you have some voodoo for that, I'd be curious to learn it (especially for making PlayMaker specific code only compile if necessary).
from dotween.
Thanks for the info Lazlo. And I have voodoo! I have! But it's so simple it's called boodoo!
With DOTween, depending how I implement extra-plugins features, I either add an extension methods class file with an "addon" file extension, and rename that to "cs" in case I find the required plugin, or I simply write conditionals and add Unity defines automatically.
from dotween.
@Demigiant & @lazlo-bonin
Tl;Dr +1
Just wanted to say it's great you guys got your heads together on this. I use DOTween and own-pending-integration Chronos. Very happy to hear this will be one fewer thing to worry about :)
from dotween.
Sorry to necropost but for anyone looking to quickly use Dotween Pro with Chronos here's what I did to add support.
make the extension method as mentioned above by lazlo-bonin here
all changes in DotweenAnimation.cs
//at the top of script
using Chronos;
//add these variables
public bool useChronosTimescale = false;
public Timeline myTimeline;
// find this line
// tween.SetUpdate(isIndependentUpdate);
//and add this below it.
if (useChronosTimescale)
tween.RegisterTimeline(myTimeline);
then in DotweenAnimationEditor.cs:
// add to top
using Chronos;
//under this line
//_src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
//add this:
if (_src.isIndependentUpdate)
{
src.useChronosTimescale = EditorGUILayout.Toggle("Use Chronos TimesScale", _src.useChronosTimescale);
if (_src.useChronosTimescale)
_src.myTimeline = EditorGUILayout.ObjectField(_src.myTimeline, typeof(Timeline), true) as Timeline; //(_src.endValueTransform, typeof(Transform), true) as Transform
}
So now, if you set the bool Ignore Timescale in the editor a second bool will show to use Chronos or not. Drag and drop in your Timeline component and Enjoy!
from dotween.
Took a while, but I finally made some tests.
DOTween works with negative timeScales (meaning it plays backwards instead of forwards), so that part is good. To attach a tween to a Chronos timeline, Lazlo suggested to use an update routine, so this should work:
myTween.OnUpdate(()=> myTween.timeScale = myChronosTimeline.timeScale);
I don't have Chronos, so if some user is interested and can check this out it would be great :)
this worked great thanks
from dotween.
This seems to work, except if I pause, and then try to resume, the tween doesn't resume. Does anyone have pausing (set timeScale to 0) working?
from dotween.
I'm having the same problem
from dotween.
Related Issues (20)
- OnComplete problem (again of course) with singleton classes
- How to make OnUpdate and ChangeEndValue work properly?
- Index out of range error
- Startup errors not giving detailed warnings when default logging enabled
- DOComplete -> TweenManager.FilteredOperation: IndexOutOfRangeException (Possibly related to SetTweensCapacity?)
- [Feature Request] Assembly Definition & Version Define Resource HOT 1
- The DOTweenPath won't rotate or move with the parent
- WaitForCompletion stuck on recycled tween
- Can Dojump use endvalues ββthat change in real time?
- DoPath - Change waypoints during tween is running
- Combining Eases HOT 1
- UI Tweening works unreliably HOT 7
- NaN Input Error HOT 2
- Upgrading to Unity 6 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
- SetDelay is appending interval between two tween Joined in sequence HOT 2
- DOTween adds 2.7MB to WebGL build HOT 1
- Is DOJump not supported for Kinematic 3D Rigidbodies?
- Unity using DOTween pro UI creates ghost effect HOT 5
- Does not support the latest 6 preview?
- Demo link is no longer operational
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotween.