- Home /
Unity 5 troubles with Catlike Coding Tutorials
So, I am trying to learn how to effectively use and code splines in Unity. It's for a project I am working where I need the characters to follow very particular paths.
So I am working on Catlike Coding's tutorial (it seemed the most complete) and I am running into:
Assets/_Scripts/BezierCurve.cs(21,57): error CS1501: No overload for method
GetPoint' takes
4' argumentsAssets/_Scripts/BezierCurve.cs(21,34): error CS1502: The best overloaded method match for
UnityEngine.Transform.TransformPoint(UnityEngine.Vector3)' has some invalid arguments - Assets/_Scripts/BezierCurve.cs(21,34): error CS1503: Argument
#1' cannot convertobject' expression to type
UnityEngine.Vector3'
And then again for line 27, the same 3 errors for 6 total errors.
using UnityEngine;
using System.Collections;
public class BezierCurve : MonoBehaviour {
public Vector3[] points;
public void Reset () {
points = new Vector3[] {
new Vector3(1f, 0f, 0f),
new Vector3(2f, 0f, 0f),
new Vector3(3f, 0f, 0f),
new Vector3(4f, 0f, 0f)
};
}
public Vector3 GetPoint (float t) {
return transform.TransformPoint (Bezier.GetPoint (points [0], points [1], points [2], points[3], t));
}
public Vector3 GetVelocity (float t) {
return transform.TransformPoint (Bezier.GetFirstDerivative (points [0], points [1], points [2], points[3],
transform.position));
}
public Vector3 GetDirection (float t) {
return GetVelocity (t).normalized;
}
}
I knew I was running into problems sooner when I couldn't even get the interpolation line to appear between the first and last point. I have double checked that my code matches his code to this point.
I cannot figure out how to fix these overloads. I'm pretty new to Unity and C#. I'm not against assets, and I know there are spline assets out there, but assets won't make me a better coder or understand the workings any better so I am trying to stay as close to coding as I can for the things than can be coded.
Thanks much for any help.
I skimmed the turotial. Seems like line 21 should be
public Vector3 GetPoint (float t) {
return transform.TransformPoint(Bezier.GetPoint(points[0], points[1], points[2], t));
}
Perhaps removing points[3] from line 27 fixes those errors as well.
The end of the tutorial has all 4 points and t as arguments.
The problem is that a Vector3 only takes 3 arguments. I have no idea how he's overloading with 2 more arguments now.