1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-04 14:24:55 +08:00

[BUGFIX] Fixed DOJump bug when a SetDelay was chained to it

This commit is contained in:
Demigiant 2018-05-31 20:35:03 +02:00
parent 0821831f12
commit 53bc29474c
48 changed files with 60 additions and 36 deletions

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween public class DOTween
{ {
/// <summary>DOTween's version</summary> /// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.730"; public static readonly string Version = "1.1.735";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -37,7 +37,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' ">
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;COMPATIBLE</DefineConstants> <DefineConstants>TRACE;COMPATIBLE,RIGIDBODY</DefineConstants>
<DocumentationFile>..\bin\DOTween.XML</DocumentationFile> <DocumentationFile>..\bin\DOTween.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>1573</NoWarn> <NoWarn>1573</NoWarn>

View File

@ -466,8 +466,14 @@ namespace DG.Tweening
bool offsetYSet = false; bool offsetYSet = false;
Sequence s = DOTween.Sequence(); Sequence s = DOTween.Sequence();
#if COMPATIBLE #if COMPATIBLE
Tween yTween = DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
.SetLoops(numJumps * 2, LoopType.Yoyo);
s.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration) s.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration)
#else #else
Tween yTween = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
.SetLoops(numJumps * 2, LoopType.Yoyo);
s.Append(DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue.x, 0, 0), duration) s.Append(DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue.x, 0, 0), duration)
#endif #endif
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear) .SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
@ -477,23 +483,17 @@ namespace DG.Tweening
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue.z), duration) ).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue.z), duration)
#endif #endif
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear) .SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
#if COMPATIBLE ).Join(yTween)
).Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, jumpPower, 0), duration / (numJumps * 2)) .SetTarget(target).SetEase(DOTween.defaultEaseType);
#else yTween.OnUpdate(() => {
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, jumpPower, 0), duration / (numJumps * 2)) if (!offsetYSet) {
#endif offsetYSet = true;
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad) offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
.SetLoops(numJumps * 2, LoopType.Yoyo).SetRelative() }
).SetTarget(target).SetEase(DOTween.defaultEaseType) Vector3 pos = target.position;
.OnUpdate(() => { pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
if (!offsetYSet) { target.MovePosition(pos);
offsetYSet = true; });
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
}
Vector3 pos = target.position;
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
target.MovePosition(pos);
});
return s; return s;
} }
@ -976,25 +976,49 @@ namespace DG.Tweening
float offsetY = -1; float offsetY = -1;
bool offsetYSet = false; bool offsetYSet = false;
// Separate Y Tween so we can elaborate elapsedPercentage on that insted of on the Sequence
// (in case users add a delay or other elements to the Sequence)
Sequence s = DOTween.Sequence(); Sequence s = DOTween.Sequence();
Tween yTween = DOTween.To(() => target.position, x => target.position = x, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
.SetLoops(numJumps * 2, LoopType.Yoyo);
s.Append(DOTween.To(() => target.position, x => target.position = x, new Vector3(endValue.x, 0, 0), duration) s.Append(DOTween.To(() => target.position, x => target.position = x, new Vector3(endValue.x, 0, 0), duration)
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear) .SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, 0, endValue.z), duration) ).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, 0, endValue.z), duration)
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear) .SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, jumpPower, 0), duration / (numJumps * 2)) ).Join(yTween)
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative() .SetTarget(target).SetEase(DOTween.defaultEaseType);
.SetLoops(numJumps * 2, LoopType.Yoyo) yTween.OnUpdate(() => {
).SetTarget(target).SetEase(DOTween.defaultEaseType) if (!offsetYSet) {
.OnUpdate(() => { offsetYSet = true;
if (!offsetYSet) { offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
offsetYSet = true; }
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY; Vector3 pos = target.position;
} pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
Vector3 pos = target.position; target.position = pos;
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad); });
target.position = pos;
});
return s; return s;
// Sequence s = DOTween.Sequence();
// s.Append(DOTween.To(() => target.position, x => target.position = x, new Vector3(endValue.x, 0, 0), duration)
// .SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
// ).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, 0, endValue.z), duration)
// .SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
// ).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
// .SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
// .SetLoops(numJumps * 2, LoopType.Yoyo)
// ).SetTarget(target).SetEase(DOTween.defaultEaseType)
// .OnUpdate(() => {
// if (!offsetYSet) {
// offsetYSet = true;
// offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
// }
// Vector3 pos = target.position;
// Debug.Log(offsetY + " > " + s.ElapsedDirectionalPercentage());
// pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
// target.position = pos;
// });
// return s;
} }
/// <summary>Tweens a Transform's localPosition to the given value, while also applying a jump effect along the Y axis. /// <summary>Tweens a Transform's localPosition to the given value, while also applying a jump effect along the Y axis.
/// Returns a Sequence instead of a Tweener. /// Returns a Sequence instead of a Tweener.

View File

@ -37,7 +37,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' ">
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;COMPATIBLE</DefineConstants> <DefineConstants>TRACE;COMPATIBLE,RIGIDBODY</DefineConstants>
<DocumentationFile>..\bin\DOTween43.xml</DocumentationFile> <DocumentationFile>..\bin\DOTween43.xml</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>1573</NoWarn> <NoWarn>1573</NoWarn>

View File

@ -37,7 +37,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' ">
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;COMPATIBLE</DefineConstants> <DefineConstants>TRACE;COMPATIBLE,RIGIDBODY</DefineConstants>
<DocumentationFile>..\bin\DOTween46.xml</DocumentationFile> <DocumentationFile>..\bin\DOTween46.xml</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>1573</NoWarn> <NoWarn>1573</NoWarn>

View File

@ -37,7 +37,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' ">
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;COMPATIBLE</DefineConstants> <DefineConstants>TRACE;COMPATIBLE,RIGIDBODY</DefineConstants>
<DocumentationFile>..\bin\DOTween50.xml</DocumentationFile> <DocumentationFile>..\bin\DOTween50.xml</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>1573</NoWarn> <NoWarn>1573</NoWarn>

View File

@ -37,7 +37,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CompatibilityMode|AnyCPU' ">
<OutputPath>..\bin\Editor\</OutputPath> <OutputPath>..\bin\Editor\</OutputPath>
<DefineConstants>TRACE;COMPATIBLE</DefineConstants> <DefineConstants>TRACE;COMPATIBLE,RIGIDBODY</DefineConstants>
<DocumentationFile>..\bin\Editor\DOTweenEditor.XML</DocumentationFile> <DocumentationFile>..\bin\Editor\DOTweenEditor.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
screenshots/pro_manager.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB