- Home /
Question by
Le-Capitaine · Mar 16, 2014 at 05:49 PM ·
c#arrayssyntaxtransform.
What's the syntax to get an object's transform (as a Vector3) inside an ArrayList?
I've been trying to implement a camera path based on control points, but I can't figure out the syntax to use. Here's the code as it is so far:
public ArrayList controlPoints;
private int currentCP;
private int nextCP;
void Update ()
{
if (transform == controlPoints[nextCP].transform) {
currentCP = nextCP;
nextCP++;
transform = Vector3.Slerp (controlPoints [currentCP], controlPoints [nextCP], 3);
}
}
Comment
Answer by Eric5h5 · Mar 16, 2014 at 05:54 PM
You would not use ArrayList; it's untyped and obsolete. Use a standard array.
public Transform[] controlPoints;
If you need to add/remove from the array, use a List
public List<Transform> controlPoints;
Your answer
![](https://koobas.hobune.stream/wayback/20220613140410im_/https://answers.unity.com/themes/thub/images/avi.jpg)