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
0
Question by kyoujiru33 · Apr 26, 2014 at 05:58 PM · vector3coordinates

Vector 3 moves object to wrong location?

I tried to make an object move to a position using a Vector 3. According to the Unity Script Reference for Vector 3, saying Vector3(0,1,0) should cause the object to move up. Instead, my object is moving to what seems to be a random point on my map (random in that I don't know why the object is moving over there). I even thought that maybe I needed to do Vector3(object coordinate, coordinate I want to go to, object coordinate) but that just shot the object out of the map and into the middle of nowhere. Maybe I'm misunderstanding how to use Vector3 properly?

So here is my code:

 var coins : int;
 
 function Awake () 
 {
 coins=1;
 }
 
 function Update () {
 
 }
 
 function OnTriggerEnter(other : Collider)
 {
 if (other.tag == "coin")
 {
 Destroy(other.gameObject);
 coins--;
 Debug.Log(coins);
 }
 
     if (other.tag == "Finish")
     {
         if (coins == 0)
         {
         Debug.Log("working");
         var obj = (GameObject.FindGameObjectWithTag("Door"));
         {
         if(obj.name == "Door");
         obj.transform.position = Vector3(0,1,0);
         }
         }
     }
 }
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

2 Replies

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

Answer by kyoujiru33 · Apr 27, 2014 at 12:51 AM

I figured out what the problem was. Apparently if you place an object in an empty that doesn't have the same coordinates as the object, then using Vector3 movement causes the object to go to a location based on the location of the object and the empty. I just removed the object from the empty and now the Vector3 is doing its job. Unity is so confusing sometimes...

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 meat5000 ♦ · Apr 27, 2014 at 12:53 AM 0
Share

In Inspector the values of Transform are Local, if the object is a child. Setting these to 0,0,0 will place the object at the centre of its parent.

avatar image kyoujiru33 · Apr 27, 2014 at 01:25 AM 0
Share

Oh! Thank you, I didn't know that. I will keep that in $$anonymous$$d.

avatar image
0

Answer by getyour411 · Apr 26, 2014 at 06:15 PM

Setting transform.position to a Vector3 like that is not a 'move' (magnitude/direction) per se, it's like a miniteleport. If you want to move (0,1,0) you need to use a move function; Google "Unity move object", look at Translate, rigidbody, CharacterController, etc.

Comment
Add comment · Show 1 · 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 kyoujiru33 · Apr 26, 2014 at 06:21 PM 0
Share

I know that it teleports, it's just not teleporting up to the position I want it at. It's teleporting to a point across the map.

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

Calculate shortest distance between two objects 1 Answer

how to create an outlined polygon with vector3 coordinates? 0 Answers

Find point on circle 1 Answer

How to use spherical coordinates in unity? 0 Answers

Help positioning an object on a 2D plane 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