mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
Modified DOJump shortcuts so the endValue is fully considered, Y included
This commit is contained in:
parent
2679dd4c25
commit
24b118f814
@ -759,6 +759,10 @@
|
||||
<param name="includeLoops">If TRUE returns the elapsed percentage since startup loops included,
|
||||
otherwise the elapsed percentage within the current loop cycle</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.ElapsedDirectionalPercentage(DG.Tweening.Tween)">
|
||||
<summary>Returns the elapsed percentage (0 to 1) of this tween (delays exluded),
|
||||
based on a single loop, and calculating eventual backwards Yoyo loops as 1 to 0 instead of 0 to 1</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.IsActive(DG.Tweening.Tween)">
|
||||
<summary>Returns FALSE if this tween has been killed.
|
||||
<para>BEWARE: if this tween is recyclable it might have been spawned again for another use and thus return TRUE anyway.</para>
|
||||
@ -1054,11 +1058,12 @@
|
||||
<param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
<param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
@ -1247,20 +1252,22 @@
|
||||
<param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
Setting it to 0 will shake along a single direction.</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z localPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,11 +43,12 @@
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's X position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -759,6 +759,10 @@
|
||||
<param name="includeLoops">If TRUE returns the elapsed percentage since startup loops included,
|
||||
otherwise the elapsed percentage within the current loop cycle</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.ElapsedDirectionalPercentage(DG.Tweening.Tween)">
|
||||
<summary>Returns the elapsed percentage (0 to 1) of this tween (delays exluded),
|
||||
based on a single loop, and calculating eventual backwards Yoyo loops as 1 to 0 instead of 0 to 1</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.IsActive(DG.Tweening.Tween)">
|
||||
<summary>Returns FALSE if this tween has been killed.
|
||||
<para>BEWARE: if this tween is recyclable it might have been spawned again for another use and thus return TRUE anyway.</para>
|
||||
@ -1054,11 +1058,12 @@
|
||||
<param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
<param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
@ -1247,20 +1252,22 @@
|
||||
<param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
Setting it to 0 will shake along a single direction.</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z localPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,11 +43,12 @@
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's X position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -759,6 +759,10 @@
|
||||
<param name="includeLoops">If TRUE returns the elapsed percentage since startup loops included,
|
||||
otherwise the elapsed percentage within the current loop cycle</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.ElapsedDirectionalPercentage(DG.Tweening.Tween)">
|
||||
<summary>Returns the elapsed percentage (0 to 1) of this tween (delays exluded),
|
||||
based on a single loop, and calculating eventual backwards Yoyo loops as 1 to 0 instead of 0 to 1</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.IsActive(DG.Tweening.Tween)">
|
||||
<summary>Returns FALSE if this tween has been killed.
|
||||
<para>BEWARE: if this tween is recyclable it might have been spawned again for another use and thus return TRUE anyway.</para>
|
||||
@ -1054,11 +1058,12 @@
|
||||
<param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
<param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
@ -1247,20 +1252,22 @@
|
||||
<param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
Setting it to 0 will shake along a single direction.</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z localPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,11 +43,12 @@
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's X position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,14 +6,16 @@ public class Jump : BrainBase
|
||||
{
|
||||
public Transform target;
|
||||
public Vector3 jump = new Vector3(4, 3, 0);
|
||||
public float jumpHeight = 3;
|
||||
public int numJumps = 1;
|
||||
public float duration = 1;
|
||||
public Ease ease = Ease.OutQuad;
|
||||
public int loops = -1;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
target.DOJump(jump, numJumps, duration).SetEase(ease).SetLoops(-1, LoopType.Yoyo);
|
||||
target.DOJump(jump, jumpHeight, numJumps, duration).SetEase(ease).SetLoops(loops, LoopType.Yoyo);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
UnityTests.Unity5/Assets/_Tests/_Shared Sprites/Spaceship.png
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/_Shared Sprites/Spaceship.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@ -0,0 +1,55 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30b9eaf483abe564a95121a10370d87e
|
||||
timeCreated: 1431943514
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
filterMode: 1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 8
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.0.725";
|
||||
public static readonly string Version = "1.0.735";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -432,36 +432,41 @@ namespace DG.Tweening
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Rigidbody target, Vector3 endValue, int numJumps, float duration, bool snapping = false)
|
||||
public static Sequence DOJump(this Rigidbody target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
return DOTween.Sequence()
|
||||
float offsetY = endValue.y - target.position.y;
|
||||
Sequence s = DOTween.Sequence()
|
||||
#if COMPATIBLE
|
||||
.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration)
|
||||
#else
|
||||
.Append(DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue.x, 0, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
)
|
||||
#if COMPATIBLE
|
||||
.Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, 0, endValue.z), duration)
|
||||
).Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, 0, endValue.z), duration)
|
||||
#else
|
||||
.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
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
|
||||
)
|
||||
#if COMPATIBLE
|
||||
.Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, endValue.y, 0), duration / (numJumps * 2))
|
||||
).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, endValue.y, 0), duration / (numJumps * 2))
|
||||
).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)
|
||||
)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
Vector3 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -778,51 +783,61 @@ namespace DG.Tweening
|
||||
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a Transform's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// <summary>Tweens a Transform's position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Transform target, Vector3 endValue, int numJumps, float duration, bool snapping = false)
|
||||
public static Sequence DOJump(this Transform target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
return DOTween.Sequence()
|
||||
float offsetY = endValue.y - target.position.y;
|
||||
Sequence s = DOTween.Sequence()
|
||||
.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)
|
||||
).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, endValue.y, 0), duration / (numJumps * 2))
|
||||
).Join(DOTween.To(() => target.position, x => target.position = x, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
Vector3 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.position = pos;
|
||||
});
|
||||
return s;
|
||||
}
|
||||
/// <summary>Tweens a Transform's X/Z localPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOLocalJump(this Transform target, Vector3 endValue, int numJumps, float duration, bool snapping = false)
|
||||
public static Sequence DOLocalJump(this Transform target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
return DOTween.Sequence()
|
||||
float offsetY = endValue.y - target.localPosition.y;
|
||||
Sequence s = DOTween.Sequence()
|
||||
.Append(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(endValue.x, 0, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
)
|
||||
.Join(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, 0, endValue.z), duration)
|
||||
).Join(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, 0, endValue.z), duration)
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
|
||||
)
|
||||
.Join(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, endValue.y, 0), duration / (numJumps * 2))
|
||||
).Join(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
Vector3 pos = target.localPosition;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.localPosition = pos;
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Transform's position through the given path waypoints, using the chosen path algorithm.
|
||||
|
||||
@ -421,6 +421,19 @@ namespace DG.Tweening
|
||||
}
|
||||
return t.position / t.duration;
|
||||
}
|
||||
/// <summary>Returns the elapsed percentage (0 to 1) of this tween (delays exluded),
|
||||
/// based on a single loop, and calculating eventual backwards Yoyo loops as 1 to 0 instead of 0 to 1</summary>
|
||||
public static float ElapsedDirectionalPercentage(this Tween t)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float perc = t.position / t.duration;
|
||||
bool isInverse = t.completedLoops > 0 && t.loopType == LoopType.Yoyo && t.completedLoops % 2 != 0;
|
||||
return isInverse ? 1 - perc : perc;
|
||||
}
|
||||
|
||||
/// <summary>Returns FALSE if this tween has been killed.
|
||||
/// <para>BEWARE: if this tween is recyclable it might have been spawned again for another use and thus return TRUE anyway.</para>
|
||||
|
||||
@ -95,29 +95,35 @@ namespace DG.Tweening
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The X end value to reach, and the Y jump height</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Rigidbody2D target, Vector2 endValue, int numJumps, float duration, bool snapping = false)
|
||||
public static Sequence DOJump(this Rigidbody2D target, Vector2 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
return DOTween.Sequence()
|
||||
float offsetY = endValue.y - target.position.y;
|
||||
Sequence s = DOTween.Sequence()
|
||||
#if COMPATIBLE
|
||||
.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector2(endValue.x, 0), duration)
|
||||
.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration)
|
||||
#else
|
||||
.Append(DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue.x, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
)
|
||||
#if COMPATIBLE
|
||||
.Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector2(0, endValue.y), duration / (numJumps * 2))
|
||||
).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 Vector2(0, endValue.y), duration / (numJumps * 2))
|
||||
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
Vector2 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -759,6 +759,10 @@
|
||||
<param name="includeLoops">If TRUE returns the elapsed percentage since startup loops included,
|
||||
otherwise the elapsed percentage within the current loop cycle</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.ElapsedDirectionalPercentage(DG.Tweening.Tween)">
|
||||
<summary>Returns the elapsed percentage (0 to 1) of this tween (delays exluded),
|
||||
based on a single loop, and calculating eventual backwards Yoyo loops as 1 to 0 instead of 0 to 1</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.IsActive(DG.Tweening.Tween)">
|
||||
<summary>Returns FALSE if this tween has been killed.
|
||||
<para>BEWARE: if this tween is recyclable it might have been spawned again for another use and thus return TRUE anyway.</para>
|
||||
@ -1054,11 +1058,12 @@
|
||||
<param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
<param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
@ -1247,20 +1252,22 @@
|
||||
<param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
Setting it to 0 will shake along a single direction.</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z position to the given value, while also applying a jump effect along the Y axis.
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOLocalJump(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Transform's X/Z localPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X/Z end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,11 +43,12 @@
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Int32,System.Single,System.Boolean)">
|
||||
<member name="M:DG.Tweening.ShortcutExtensions.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's X position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The X end value to reach, and the Y jump height</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user