Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by Eddie 2 · Jan 10, 2011 at 08:08 AM · arrayiphonevectorcastingpragmastrict

Problem accessing vector properties

Hello guys, I'm new to Unity 3D and currently im working on a iphone project using unity javascript. I encountered this compile error: BCE0019: 'x' is not a member of 'Object'.

my codes are somewhat like this:

#pragma strict

private static var pointsArray:Array ;

private static startGeneratePoints() { pointsArray = new Array(); var randomPoint:Vector3;

 for(var i:int = 0; i < 3; i++)
 {
     randomPoint = new Vector3(i,1,1);
     pointsArray.Push(randomPoints);
 }

print(pointsArray[0].x);

}

then i tried:

var tempVector2:Vector3 = pointsArray[0];

trying to assign it into a vector3, this is the error i get:

BCE0022: Cannot convert 'Object' to 'UnityEngine.Vector3'.

Then, i try to cast it to vector3:

var tempVector2:Vector3 = pointsArray[0] as Vector3;

this is the error i get:

BCE0006: 'UnityEngine.Vector3' is a value type. The 'as' operator can only be used with reference types.

Anyone got an idea on how to solve this issue? How can I get the 'x' properties of the vector3 inside an array?

Comment
Add comment · Show 3
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 Jessy · Jan 10, 2011 at 08:15 AM 0
Share

Downvoted for not taking any time to make that readable. Please put more effort into the use of the code tags.

avatar image Eddie 2 · Jan 10, 2011 at 08:23 AM 0
Share

hmm... sorry, 1st time posting here, edited, better now?

avatar image Jessy · Jan 10, 2011 at 09:12 AM 0
Share

Yep, looks great. No more downvote.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Jan 10, 2011 at 09:08 AM

There's no reason to use Array. Use List.<Vector3> instead.

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
3

Answer by Mike 3 · Jan 10, 2011 at 08:29 AM

Try add in

#pragma downcast

at the top of your file, which should allow it to implicitly (but not dynamically) cast to the right type

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 Eddie 2 · Jan 10, 2011 at 08:45 AM 0
Share

I tried adding this before, it won't work :(

avatar image Mike 3 · Jan 10, 2011 at 12:54 PM 0
Share

In that case, +1 for using List. :D

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Unity3D - Playback object array of position (with dynamic velocity) 0 Answers

Getting a 2d Sprite to move over time to an Array 1 Answer

Object moves to new location in vector array 1 Answer

No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(Object)' was found. 1 Answer

Object to Foo is okay, but Object[] to Foo[] gives error. 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