- Home /
Itween CRSpline to BezQuad
Hello, I'm making a game in college and I'm using ITween path (CRSpline), but need something more fluid, I saw that in ITween, Bob Berkebile used the code for CRSpline in this post written by Andeeee http://forum.unity3d.com/threads/32954-Waypoints-and-constant-variable-speed-problems?p=213942#post213942
Is there any way to implement the QuadBez inside ITween, or some other similar solution? :)
public class QuadBez {
public Vector3 st, en, ctrl;
public QuadBez(Vector3 st, Vector3 en, Vector3 ctrl) {
this.st = st;
this.en = en;
this.ctrl = ctrl;
}
public Vector3 Interp(float t) {
float d = 1f - t;
return d * d * st + 2f * d * t * ctrl + t * t * en;
}
public Vector3 Velocity(float t) {
return (2f * st - 4f * ctrl + 2f * en) * t + 2f * ctrl - 2f * st;
}
Here is my current code
if (Input.Get$$anonymous$$ouseButtonDown (0)) {
targetPosition = Camera.mainCamera.ScreenToWorldPoint (new Vector3 (posX, posY, posZ));
var myPosition = this.transform.position;
var ctrlSize = Vector3.Distance (myPosition , targetPosition) * 0.5f;
Ctrl = myPosition + this.transform.forward * ctrlSize;
myPath = new Vector3[] { myPosition , Ctrl , targetPosition};
iTween.$$anonymous$$oveTo (this.gameObject, iTween.Hash ("path", myPath, "movetopath", true, "speed", 20, "easetype", iTween.EaseType.linear));
}
Answer by BobBobson108 · Mar 26, 2012 at 04:58 PM
Check out this post on my blog, I think it's exactly what you're looking for.
http://aminorcsharpblog.blogspot.com/2012/02/space-ship-game-step-1-dynamic.html