Comments (10)
Just an update. I added extensions to tween in local space of the target, that way it behaves just like following a target. I got the idea from another post. Here is the position and rotation code for it
public static TweenerCore<Vector3, Vector3, VectorOptions> DOMoveInTargetLocalSpace(this Transform transform, Transform target, Vector3 targetLocalEndPosition,float duration)
{
var t = DOTween.To(
() => transform.position - target.transform.position, // Value getter
x => transform.position = x + target.transform.position, // Value setter
targetLocalEndPosition,
duration);
t.SetTarget(transform);
return t;
}
public static TweenerCore<Quaternion, Quaternion, NoOptions> DORotateQuaternionLocalSpace(
this Transform transform,
Transform target,
Quaternion endValue,
float duration)
{
TweenerCore<Quaternion, Quaternion, NoOptions> t = DOTween.To<Quaternion, Quaternion, NoOptions>((ABSTweenPlugin<Quaternion, Quaternion, NoOptions>) PureQuaternionPlugin.Plug(), (DOGetter<Quaternion>) (() => Quaternion.Inverse(target.rotation)*transform.rotation), (DOSetter<Quaternion>) (x => transform.rotation = target.rotation * x), endValue, duration);
t.SetTarget<TweenerCore<Quaternion, Quaternion, NoOptions>>((object) transform);
return t;
}
To follow the object exactly use Vector3.zero and Quaternion.Identity for the targetLocalEndPosition and endvalue
from dotween.
Hello,
I thought about it, but the problem with a "follow tween" would be that it wouldn't be able to be rewinded or manipulated as the other tweens (because in order to allow it to readapt correctly to its follow target's position every frame, it would need to change its start value too). I'm thinking that maybe I could add an extra "DOTweenFollow" component just for that. What you think of it?
from dotween.
Hi,
I was thinking of something much more simpler (though a "follow tween" would be great as well). The idea is just to get the position of the GameObject as the destination when the tween start.
For example, if I want some text to move from the center of the screen to an element of my HUD, I'd like to set the element as the destination instead of entering its coordinates. This way, if I reorganize my UI layout later, I don't have to modify my tweens.
I'd be glad to help add this feature if it's ok with you.
Thanks
from dotween.
Hello,
Ah! That would be indeed much simpler! I'm going to see if I can add it later today then :) In the meantime, if you don't have access to DOTween Pro's private download area, follow these instructions, so I can send you a link as soon as it's done.
Cheers
from dotween.
Voilà :)
There is now a switch button next to the Vector3 field of Move tweens, which can be used to tell DOTweenAnimation to use a target instead of a Vector3 value
from dotween.
Awesome! Thanks for the quick update :).
from dotween.
Would the tween auto update the destination position if the gameobject moves away before the tween finishes?
from dotween.
does the tween update its destination when the transform moves while the tween is happening ?
from dotween.
No, the position is evaluated only when the tween starts.
from dotween.
Vote for the DOTweenFollow idea, I would definitely use that
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.