• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rajasekhar · Apr 14, 2010 at 08:11 AM · iphone

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Peter G · Apr 14, 2010 at 10:24 AM

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

waypoints : Transform[];

or

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 ) );
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image weg · Dec 08, 2013 at 11:12 AM 0
Share

Hello there,

Thank you for solving the problem but when I am changing to your respected code, I'm getting error IndexOutOfRangeException: Array index is out of range . Please help me to sort out this problem.

Thanks in advance.

Cheers

avatar image Peter G · Dec 10, 2013 at 01:58 AM 0
Share

That just means you're trying to access an element that isn't there i.e. accessing the 11th item if the array only holds 10. You probably have currentWaypoint go beyond the bounds of the array at some point.

avatar image
0

Answer by StephanK · Apr 14, 2010 at 08:21 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Rafi-Khan · Sep 11, 2014 at 07:20 AM

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 ) );
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by KrzyKu · May 23, 2015 at 07:51 AM

fix error add before "var RelativeWaypointPosition" put this code:

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

high score name entry iphone 1 Answer

Help Marshal.StructureToPtr only IOS platform problem 0 Answers

altimeter gauge... 1 Answer

Is there a way to visually show the order in which geometry was rendered in your scene. 1 Answer

How to support Retina display 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges