• 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 /
  • Help Room /
avatar image
0
Question by JockeB · Jan 19, 2017 at 04:32 PM · positionpositioningcoordinatespositions

X coordinates isn't the same on my gameobjects when on same position.

Hi. When I place my gameobjects on top of each other they don't get the same x coordinates even tho i they are in the exact same spots. When placed on top of each other GameObject1 get the position x=-4.3 but my GameObject2 get the position x=77.7. Is there any way to fix this? I need this to work for this code to work:

  void OnTriggerEnter2D(Collider2D other)
     {
         if (other.tag == "Player")  {
             if (facingRight && other.transform.position.x < transform.position.x)
             {
                 flipFacing();
                 
             }
             else if (!facingRight && other.transform.position.x > transform.position.x)
             {
                 flipFacing();
             }
             
             canFlip = false;
             charging = true;
             startChargeTime = Time.time + chargeTime;
         }
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
0

Answer by Placeholder123 · Apr 30, 2020 at 07:51 PM

Are one of the objects a child of another object? Because if an object is a child then its position will be relative to its parent

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Player Prefs not setting the position at start of the game 0 Answers

Mixup in global and local positions? 0 Answers

i want to find object x position value at run time please help me 0 Answers

Spawn Procedural Planet at parent's position 0 Answers

Can you help explain this positioning conundrum to me! 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges