1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00

Fixed path orientation not ending correctly with non-close Linear paths

This commit is contained in:
Daniele Giardini 2015-03-24 12:32:09 +01:00
parent 4e668f0928
commit 7597760e6e
31 changed files with 71 additions and 110 deletions

View File

@ -4,110 +4,5 @@ using UnityEngine;
public class Paths : BrainBase
{
public Ease ease = Ease.Linear;
public AxisConstraint lockPosition;
public AxisConstraint lockRotation0, lockRotation1;
public LoopType loopType = LoopType.Yoyo;
public PathMode pathMode;
public int pathResolution = 10;
public bool closePaths;
public Vector3 forward = Vector3.forward;
public Color[] pathsColors = new Color[2];
public Transform[] targets;
Tween controller;
void Start()
{
// Vector3[] path = new[] {
// new Vector3(0,1,0),
// new Vector3(1,2,0),
// new Vector3(2,1,0),
// new Vector3(2,0,0)
// };
// TweenParams tp = new TweenParams()
// .SetEase(ease)
// .SetLoops(-1, loopType);
// AxisConstraint lockRotation = lockRotation0 | lockRotation1;
// // Relative VS non relative
// controller = targets[0].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(0.1f, forward)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// targets[1].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[1])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(targets[2], forward)
// .SetAs(tp)
// .Pause();
// // Linear VS curved
// targets[2].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(new Vector3(3, 0, 0), forward)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// targets[3].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(0.1f, forward)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// // Linear VS curved no lookAt
// targets[4].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// targets[5].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// // Linear VS curved top-down
// path = new[] {
// new Vector3(0,0,1),
// new Vector3(1,0,2),
// new Vector3(2,0,1),
// new Vector3(2,0,0)
// };
// targets[6].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(0.1f, forward)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// targets[7].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
// .SetOptions(closePaths, lockPosition, lockRotation)
// .SetLookAt(0.1f, forward)
// .SetAs(tp)
// .SetRelative()
// .Pause();
// // Log lengths
// controller.ForceInit();
// Debug.Log("Controller path length: " + controller.PathLength());
}
void OnGUI()
{
DGUtils.BeginGUI();
DGUtils.GUIScrubber(controller);
GUILayout.BeginHorizontal();
if (GUILayout.Button("TogglePause")) DOTween.TogglePauseAll();
if (GUILayout.Button("Goto 1.5")) DOTween.GotoAll(1.5f);
if (GUILayout.Button("Kill")) DOTween.KillAll();
GUILayout.EndHorizontal();
DGUtils.EndGUI();
}
}

View File

@ -12,8 +12,14 @@ public class TempTests : BrainBase
{
public Transform target;
void Start()
IEnumerator Start()
{
DOTween.To(()=>new Vector3(0,2,0), x=>target.position = x, new Vector3(2,4,2), 2);
yield return new WaitForSeconds(0.6f);
Tweener t = target.DOLocalMove(new Vector3(4, 4, 0), 3);
yield return new WaitForSeconds(0.1f);
t.ChangeEndValue(new Vector3(0, 8, 0));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: 3d3db7798b61f454cb36c9f158b1b48a
timeCreated: 1427192225
licenseType: Pro
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: 512
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:

View File

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

View File

@ -141,9 +141,14 @@ namespace DG.Tweening.Plugins
lookAtP = tPos + path.wps[path.linearWPIndex] - path.wps[path.linearWPIndex - 1];
} else {
float lookAheadPerc = pathPerc + options.lookAhead;
if (lookAheadPerc > 1) lookAheadPerc = (options.isClosedPath ? lookAheadPerc - 1 : 1.00001f);
if (lookAheadPerc > 1) lookAheadPerc = (options.isClosedPath ? lookAheadPerc - 1 : path.type == PathType.Linear ? 1 : 1.00001f);
lookAtP = path.GetPoint(lookAheadPerc);
}
if (path.type == PathType.Linear) {
// Check if it's the last waypoint, and keep correct direction
Vector3 lastWp = path.wps[path.wps.Length - 1];
if (lookAtP == lastWp) lookAtP = tPos == lastWp ? lastWp + (lastWp - path.wps[path.wps.Length - 2]) : lastWp;
}
Vector3 transUp = trans.up;
// Apply basic modification for local position movement
if (options.useLocalPosition && options.parent != null) lookAtP = options.parent.TransformPoint(lookAtP);

Binary file not shown.

Binary file not shown.

Binary file not shown.