I am currently in the process of converting a project from javascript into C sharp, this is the only problem I have had so far. Here is the code I have:
public class SpawnObjects : MonoBehaviour {
public int numberOfHills = 10;
private Vector3[] aPos;
void Start() {
aPos = new Vector3[numberOfHills];
Array.Sort(aPos, delegate(Vector3 first, Vector3 second){
return first.y.CompareTo(second.y);
});
And the error I recieve: error CS0103: The name `Array’ does not exist in the current context
Also if I change the code to:
public class SpawnObjects : MonoBehaviour {
public int numberOfHills = 10;
private Vector3[] aPos;
void Start() {
aPos = new Vector3[numberOfHills];
aPos.Sort(aPos, delegate(Vector3 first, Vector3 second){
return first.y.CompareTo(second.y);
});
I recieve:
error CS0176: Static member `System.Array.Sort<UnityEngine.Vector3>(UnityEngine.Vector3[], System.Comparison<UnityEngine.Vector3>)’ cannot be accessed with an instance reference, qualify it with a type name instead
Can anyone shed some light on whats happening?
Cheers.