Skip to content

Commit

Permalink
Added Rigidbody.DOPath/DOLocalPath methods (beware: they don't work o…
Browse files Browse the repository at this point in the history
…n windows phone/store)
  • Loading branch information
Demigiant committed Dec 23, 2016
1 parent 5f28d4b commit 8cabb36
Show file tree
Hide file tree
Showing 56 changed files with 309 additions and 44 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity5/Assets/_Tests PRO/Paths.unity
Binary file not shown.
27 changes: 27 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class IndexOutOfRange02 : BrainBase
{
public Transform[] targets;

IEnumerator Start()
{
DOTween.Init (true, false, LogBehaviour.ErrorsOnly).SetCapacity (1000, 100);
DOTween.defaultAutoPlay = AutoPlay.None;
DOTween.defaultAutoKill = false;
yield return new WaitForSeconds(1);

foreach (Transform t in targets) t.DOMoveX(10, 10).Play();
yield return new WaitForSeconds(2);

// DOTween.Clear(true);
}

void OnDestroy()
{
DOTween.Clear(true);
}
}
12 changes: 12 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange02.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions UnityTests.Unity5/Assets/_Tests/PathsFree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,31 @@
public class PathsFree : BrainBase
{
public Transform target;
public bool useRigidbody;
public bool useLocalPosition;
public float duration = 3;
public Ease ease = Ease.Linear;
public PathType pathType;
public bool closePath;
public Vector3[] waypoints;

IEnumerator Start()
void Start()
{
yield return new WaitForSeconds(1);

target.DOPath(waypoints, 3f, pathType).SetOptions(closePath).SetEase(ease)
Tween t;
if (useLocalPosition) {
t = useRigidbody
? target.GetComponent<Rigidbody>().DOLocalPath(waypoints, duration, pathType).SetOptions(closePath).SetLookAt(0.001f)
: target.DOLocalPath(waypoints, duration, pathType).SetOptions(closePath).SetLookAt(0.001f);
} else {
t = useRigidbody
? target.GetComponent<Rigidbody>().DOPath(waypoints, duration, pathType).SetOptions(closePath).SetLookAt(0.001f)
: target.DOPath(waypoints, duration, pathType).SetOptions(closePath).SetLookAt(0.001f);
}
t.SetEase(ease)
.OnWaypointChange(x=> Debug.Log("CHANGE > " + x + " - " + target.position));
if (useRigidbody && !target.GetComponent<Rigidbody>().isKinematic) {
t.OnPlay(()=> target.GetComponent<Rigidbody>().isKinematic = true);
t.OnComplete(()=> target.GetComponent<Rigidbody>().isKinematic = false);
}
}
}
Binary file modified UnityTests.Unity5/Assets/_Tests/PathsFree.unity
Binary file not shown.
2 changes: 1 addition & 1 deletion _DOTween.Assembly/DOTween/DOTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.520";
public static readonly string Version = "1.1.530";

///////////////////////////////////////////////
// Options ////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions _DOTween.Assembly/DOTween/Plugins/Options/PathOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public struct PathOptions : IPlugOptions
public Quaternion forward;
public bool useLocalPosition;
public Transform parent; // Only used with OrientType.ToPath and useLocalPosition set as TRUE
public bool isRigidbody;

internal Quaternion startupRot; // Used to reset orientation when rewinding
internal float startupZRot; // Used to store Z value in case of lock Z, in order to rotate things differently
Expand Down
7 changes: 4 additions & 3 deletions _DOTween.Assembly/DOTween/Plugins/PathPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override void SetRelativeEndValue(TweenerCore<Vector3, Path, PathOptions>
// then sets the final path version
public override void SetChangeValue(TweenerCore<Vector3, Path, PathOptions> t)
{
Transform trans = (Transform)t.target;
Transform trans = ((Component)t.target).transform;
if (t.plugOptions.orientType == OrientType.ToPath && t.plugOptions.useLocalPosition) t.plugOptions.parent = trans.parent;

if (t.endValue.isFinalized) {
Expand Down Expand Up @@ -137,7 +137,7 @@ public override void EvaluateAndApply(PathOptions options, Tween t, bool isRelat
// Public so it can be called by GotoWaypoint
public void SetOrientation(PathOptions options, Tween t, Path path, float pathPerc, Vector3 tPos, UpdateNotice updateNotice)
{
Transform trans = (Transform)t.target;
Transform trans = ((Component)t.target).transform;
Quaternion newRot = Quaternion.identity;

if (updateNotice == UpdateNotice.RewindStep) {
Expand Down Expand Up @@ -216,7 +216,8 @@ public void SetOrientation(PathOptions options, Tween t, Path path, float pathPe
}

if (options.hasCustomForwardDirection) newRot *= options.forward;
trans.rotation = newRot;
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
else trans.rotation = newRot;
}
}
}
Loading

0 comments on commit 8cabb36

Please sign in to comment.