• 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 filipemoraes · Aug 30, 2015 at 05:53 PM · gameobjects

GameObject position changes after I press the play button on Unity

The game has the following scenario:

alt text


The other objects have been disabled only to demonstrate the problem. I think to deactivate them do not influence the game, right?

This is what happens when I click play in Unity: alt text


Note that the Ground and Ground_2 objects were moved to the position (0,0) and yes, the sprite pivot is BottomLeft, so it is not centered.

Game settings:

Background alt text

Camera alt text

Camera Script

 using UnityEngine;
 using System.Collections;
 
 public class CameraSettings : MonoBehaviour {
 
     private float targetRatio = 9f/16f;
 
     // Use this for initialization
     void Start () {
         Camera cam = GetComponent<Camera>();
         cam.aspect = targetRatio;
     }
 }

Ground (Ground, Ground_2 and Ground_3) alt text

Ground Sprite (Within the GameObject "Ground" there is a sprite) alt text



What is wrong?

capturar.jpg (71.3 kB)
capturar-2.jpg (59.2 kB)
Comment
Add comment · Show 4
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 satyagames · Aug 31, 2015 at 09:12 AM 0
Share
  1. Delete Ground, Ground_2, Ground_3.... and Try to add it again

  2. Only add Ground Sprite. i mean remove the parent object (Ground, Ground_2, Ground_3)

Try above scenarios ...

avatar image filipemoraes · Aug 31, 2015 at 10:22 AM 0
Share

I deleted the objects and added again. Its work, however, the problem came back after pressing play button a few times. :( The problem is solved after I close and open the Unity3d. What is wrong? Thanks.

avatar image Mikilo · Aug 31, 2015 at 10:27 AM 0
Share

You need to solve it empirically.

Isolate, test, isolate, test.

The only thing that "might" cause a problem is BoxCollider2D and the Rigidbody2D.

Now we don't have your scene, we can not suggest other things since you have only 5 active GameObjects.

avatar image Scribe · Aug 31, 2015 at 02:20 PM 0
Share

Someone reported a similar issue recently, apparently it wa caused by the position constraints on their 2D rigidbody, I do not know how they solved it: look here

I believe it is a bug introduced since 5.1.2

0 Replies

· Add your reply
  • Sort: 

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

Why is this C# script causing lag spikes between the game objects being cycled?, 1 Answer

sync color change of objects c# 1 Answer

toggle gameObjects with a keyPress 1 Answer

What is the Performance implications of stacking gameobjects and switch between them for character customization. 1 Answer

Combine two or more gameobjects with different rigidbody values 0 Answers


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