AI Car( error is 'position' is not a member 'object')

Hi ,

down code is working in PC side, but Iphone side is not compile ,please any body help.

that error is 'position' is not a member 'object'

please very very urgent .please.............

var waypointContainer : GameObject; private var waypoints : Array; private var currentWaypoint : int = 0;

var RelativeWaypointPosition : Vector3 = transform.InverseTransformPoint( Vector3( waypoints[currentWaypoint].position.x, transform.position.y, waypoints[currentWaypoint].position.z ) );

regards raj

First, your array contains generic objects so you have to declare the type of the array

waypoints : Transform[];


waypoints : GameObject[]

Then if you used a Transform[] then your code will work, but if you use a gameobject array see below.

Vector3(waypoints[currentWaypoint].position.x, transform.position.y, waypoints[currentWaypoint].position.z ) );

to this

Vector3(waypoints[currentWaypoint].transform.position.x, transform.position.y, waypoints[currentWaypoint].transform.position.z ) );

I don't use javascript so I'm not sure how to solve this, but your problem seems to be, that your waypoints array contains 'objects' rather than GameObjects or Transforms. For waypoints[index].position to work waypoints needs to contain Transforms.

The wayPoints is only an array it contains only objects not Transforms or GameObjects as StephanK said.

private var waypoints : Array;

So you have to cast the current array object to Transform to some var as point

var point : Transform = waypoints[currentWaypoint];
now use that transform like
var RelativeWaypointPosition : Vector3 = transform.InverseTransformPoint( Vector3( point.position.x, transform.position.y, point.position.z ) );

fix error add before “var RelativeWaypointPosition” put this code:

var waypoints : Transform[];
waypoints = waypointContainer.GetComponentsInChildren.();