x


UnitySteer - Problem creating Vector3Pathway

I started taking a look at UnitySteer. Basically I have a few waypoints in my scene, and I'm trying to assign that list of Vector3's to the C5.IList that the Vector3Pathway constructor requires.

How do I convert from a List to C5.IList ?? No matter what I try it doesn't accept the conversion, and using Path.AddPoint doesn't seem to work either using the default constructor.

When trying to convert, Unity gives me the error, 'Cannot convert from the source type to the destination type'.

Here is my code

    public void Awake()
    {
        var vector3List = GetVectors();
        Path = new Vector3Pathway((C5.IList<Vector3>)vector3List, 5, true);
    }

    private IList<Vector3> GetVectors()
    {
        wayPoints = wayPointContainer.GetComponentsInChildren<Transform>();
        var vector3List = new List<Vector3>();

        foreach (Transform theTransform in wayPoints)
        {
            vector3List.Add(new Vector3(theTransform.position.x, theTransform.position.y, theTransform.position.z));
        }

        return vector3List;
    }
more ▼

asked May 29 '11 at 03:51 PM

Meltdown gravatar image

Meltdown
5.6k 18 25 49

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

What your code above is doing is trying to cast your IList into C5.IList, which is not a valid cast. There are two quick solutions I can see:

  1. Change your GetVectors so that instead of creating a System.Collections.Generic.List you instead create a C5.ArrayList
  2. On Awake, instead of attempting to cast that list, just construct a C5.ArrayList based on another collection (like the one you receive from GetVectors).
more ▼

answered May 30 '11 at 07:07 AM

Ricardo gravatar image

Ricardo
5.2k 20 32 96

Thanks will try that tonight and let you know if I come right.

May 30 '11 at 11:11 AM Meltdown

Thanks that works, although I'm still having an issue setting the Path property on my 'agent', please check it out on http://forum.unity3d.com/threads/26217-UnitySteer-steering-library-for-Unity/page5 thanks

May 30 '11 at 07:49 PM Meltdown
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x233
x42

asked: May 29 '11 at 03:51 PM

Seen: 904 times

Last Updated: May 30 '11 at 07:49 PM