Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by derrtyones · Dec 11, 2012 at 10:41 PM · javascriptgameobjectvector3

Get Vector3 position of player?

Hi,

I have a first person controller on my scene named "Player". In my script I am trying to get the position of the player in Vector3. How exactly do I do this?

This is what I tried:

 var playerObject = GameObject.Find("Player");
 var playerPos:Vector3 = playerObject;
 Debug.Log(playerPos);

This will give me an error: Cannot convert 'UnityEngine.GameObject' to 'UnityEngine.Vector3'.

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

1 Reply

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

Answer by Demigiant · Dec 11, 2012 at 10:42 PM

 var playerPos:Vector3 = playerObject.transform.position;
Comment
Add comment · Show 9 · 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 derrtyones · Dec 11, 2012 at 10:43 PM 0
Share

Thanks! $$anonymous$$y God, you are fast! :-)

avatar image Demigiant · Dec 11, 2012 at 10:45 PM 0
Share

ahah that was simple :-D

avatar image varunt314 · Oct 31, 2013 at 12:50 AM 0
Share

is there a way to store the positions( after regular time intervals) in a separate log file for later use?

avatar image Bentoon · Jan 16, 2014 at 03:51 AM 0
Share

Hmmm How come the playerObject gives me an error: BCE0005: $$anonymous$$ identifier: 'playerObject'. ? Be

avatar image RootsMJ · Apr 02, 2014 at 10:05 AM 0
Share

playerObject is the name he chose for his player object. You need to change that to whatever you've chosen to name your player.

Show more comments

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NullReferenceException in follow function 0 Answers

Move instantiated object towards player's posistion 3 Answers

Trying to make a simple inventory: 0 Answers

Need help with building system 1 Answer

How am I supposed to use SetTile( ) on a GameObject's position if its x and y values aren't integers? , 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