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
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.730";
public static readonly string Version = "1.1.735";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

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

View File

@ -466,8 +466,14 @@ namespace DG.Tweening
bool offsetYSet = false;
Sequence s = DOTween.Sequence();
#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)
#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)
#endif
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
@ -477,21 +483,15 @@ namespace DG.Tweening
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue.z), duration)
#endif
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
#if COMPATIBLE
).Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
#else
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
#endif
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
.SetLoops(numJumps * 2, LoopType.Yoyo).SetRelative()
).SetTarget(target).SetEase(DOTween.defaultEaseType)
.OnUpdate(() => {
).Join(yTween)
.SetTarget(target).SetEase(DOTween.defaultEaseType);
yTween.OnUpdate(() => {
if (!offsetYSet) {
offsetYSet = true;
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
}
Vector3 pos = target.position;
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
target.MovePosition(pos);
});
return s;
@ -976,25 +976,49 @@ namespace DG.Tweening
float offsetY = -1;
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();
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)
.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(() => {
).Join(yTween)
.SetTarget(target).SetEase(DOTween.defaultEaseType);
yTween.OnUpdate(() => {
if (!offsetYSet) {
offsetYSet = true;
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
}
Vector3 pos = target.position;
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
target.position = pos;
});
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.
/// Returns a Sequence instead of a Tweener.

View File

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

View File

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

View File

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

View File

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