- Home /
returning array of gameobjects problem
Hey guys,
I have a function thats takes a few parameters and returns an array of gameobjects.
However, no matter what I try it shows me this error(points to the return line):
"error CS0029: Cannot implicitly convert type UnityEngine.GameObject[]' to
UnityEngine.GameObject'"
Here's my code:
public class HELPER_ReturnColliderPos {
public static GameObject ReturnColliders(Vector3 point, GameObject[] gameobjects)
{
GameObject[] vectors = new GameObject[gameobjects.Length];
vectors = gameobjects;
//update collider positions and return
return vectors;
}
}
I could definitely use some input and any bit of it, is of course, much appreciated!
Answer by aldonaletto · May 26, 2013 at 09:38 PM
The function type is wrong: it should be GameObject[] (not GameObject) like below:
public static GameObject[] ReturnColliders(Vector3 point, GameObject[] gameobjects)
Ah, I was sure I tried it, guess I didn't. Thanks a bunch!
Your answer
![](https://koobas.hobune.stream/wayback/20220613102951im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Spaceship game, Pick weapon 1 Answer
Storing functions in a list/array? 1 Answer
Add a temporary variable to an array 1 Answer
How to make a List or Array of functions with type Void 4 Answers
Returning byte array from Java/Android 3 Answers