Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Objects change position when "Play" Button hit

Discussion in 'Editor & General Support' started by FishFace, Aug 4, 2011.

  1. FishFace

    FishFace

    Joined:
    Apr 20, 2011
    Posts:
    99
    Hi,

    I have got a problem specifically with one project, where I created and textured a simple room with walls attached next to it. If I know hit "Play", all the objects change position but are still attached to another...This problem I have only with this project, not with other ones. Can anyone please help?

    Thanks,
    FishFace
     
  2. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    It could happen for a lot of reasons.
    Are you using rigidbodies on the objects?

    If yes, and if they're not kinematic then the physics simulation is kicking in on the objects moving them.

    If no, maybe you have a script that moves the parent gameobject and that script starts when you hit Play.

    Also check if the camera is not the one changing position giving you the impression that all the objects moved.
     
    Last edited: Nov 12, 2019
    PhoebeMell, dadadodo and nikozhou47 like this.
  3. FishFace

    FishFace

    Joined:
    Apr 20, 2011
    Posts:
    99
    No, I removed all the mesh colliders of the gameObjects, but it did not change anything. I'm also not using rigidbodies on them, and there is no script making objects move, by the way, I connected the gameObjects through Vertex snapping , so there is no parent Object...and the Camera stays in position when the game starts...
     
  4. zine92

    zine92

    Joined:
    Nov 13, 2010
    Posts:
    1,347
    Maybe you did something in a start function in your gameObjects.
     
  5. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    This a problem tipically related to parenting. Maybe in the model side (pivot) or in Unity editor scene hierarchy. Look into the main object hierarchy.
     
    Last edited: Aug 4, 2011
    Jolan118 and SeanMayich like this.
  6. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I ran into a similar problem, but it was mainly my own absentmindedness, if you leave position keys on an object doing basic animations externally, the object will flit to that position when play is pressed

    I should work out how to get round that
     
    servetg and SeanMayich like this.
  7. FishFace

    FishFace

    Joined:
    Apr 20, 2011
    Posts:
    99
    Sorry, but it doesnt help anything, I now started also a new peoject with a downloaded model, which consists of several smaller gameobjects...and the prolem is the same here, i placed it at some position in the scene, and when I start the game, the object moves to a different position, at first I dont think it changed position, but after moving it around then the problem again occured...I am totally frustrated because of this and need urgent help!!
     
  8. FishFace

    FishFace

    Joined:
    Apr 20, 2011
    Posts:
    99
    Ah, I know what the problem is I think, Im using belnder 2.58, from where i exported the model to fbx, and "animaion enabled" was true, so that may have been the problem, now i have deavticated "animation enabled" and I hope it works now...
     
  9. FishFace

    FishFace

    Joined:
    Apr 20, 2011
    Posts:
    99
    Well from what I have tried so far it works finally :), so it was a tiny mistake due to enabling non-existing animations....
     
    Minilnur likes this.
  10. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    Glad you solved the problem! :)
    Never would have guessed it.
     
  11. denniscw

    denniscw

    Joined:
    Mar 16, 2018
    Posts:
    2
    Hi
    I also ran into similar problem. I don't have animation in my program. However, I think it doesn't hurt to try to disable it.
    Would you mind to share how to disable non-existing animations?

    Thanks in advance!
     
  12. unity_Wt4rDbZCXGnE5w

    unity_Wt4rDbZCXGnE5w

    Joined:
    Sep 25, 2017
    Posts:
    1
    I have also encountered a similar problem. I parented my camera with GvrReticlePointer and now when I hit Play the camera snaps to the origin. What is the solution?
     
  13. ElegantUniverse

    ElegantUniverse

    Joined:
    Sep 13, 2018
    Posts:
    78
    I had same problem and I solved it.
    I drag many same sprites to hierarchy so as to make an animation , I recorded its animation based on Moving position of the sprites, every time that i moved animated object to somewhere else and i hit play button it moved to first location that I made its animation. I deleted controller and its animation , it solved.
    I wrote this solution to help other friends who will encounter with this problem.
     
  14. nathi0106

    nathi0106

    Joined:
    Aug 22, 2018
    Posts:
    4
    Hi. I'm having the same problem. My player object moves up after i added a script. I could not find what is the problem? Can anyone help? I tried moving it in scene view. It does the same thing. Thanks in advance.:(

    Screenshot (67).png
     
  15. ElegantUniverse

    ElegantUniverse

    Joined:
    Sep 13, 2018
    Posts:
    78
    I think You have to set rawposition.y for your character too.
     
    nathi0106 likes this.
  16. nathi0106

    nathi0106

    Joined:
    Aug 22, 2018
    Posts:
    4
    Thank you.
     
  17. Siggytron

    Siggytron

    Joined:
    Feb 9, 2018
    Posts:
    12
    Does that mean you had to redo all of the animations?

    Or did you simply delete and then add back the same animation controller and animations and it worked?
     
  18. ElegantUniverse

    ElegantUniverse

    Joined:
    Sep 13, 2018
    Posts:
    78
    no you dont need to delete all your animations
     
  19. MyMiniGemini

    MyMiniGemini

    Joined:
    Jan 25, 2014
    Posts:
    24
    Hello
    Also had this problem, didnt have any animation, had drawn TileMap and a 2D scene, so in scene and game views positions of some prefabs were different, some would move slightly to the left, some to the right, etc. Also TileMap collider grid would move and that caused loads of trouble like character walking on water or hills, where he should collide and stop.
    I didnt find an answer here but managed solve it myself.
    So for some reason my Grid Transform/Position, the parent of TileMap had x =0; y=0; and z=1. I do not have a clue why z was 1, as it is 2D game and I never changed the value, could be some kind of default, hard to say. So yep i just changed z value to 0 and it solved everything for me.
    Great if it helped someone.
    Peace
     
  20. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    in my case I realized that the pivot of my compound mesh was not in the center, so in Play mode the child objects transforms got "corrected" and shifted away from where i placed them in Edit mode.
     
  21. servetg

    servetg

    Joined:
    Jan 22, 2021
    Posts:
    1
    My question is answered 10 years ago. THAT IS HUGE!!!! Thanks
     
  22. noneyabiznus

    noneyabiznus

    Joined:
    Oct 17, 2021
    Posts:
    7
    I'm still totally lost. What if I want animations? Then I am stuck with this problem?
     
  23. ElegantUniverse

    ElegantUniverse

    Joined:
    Sep 13, 2018
    Posts:
    78
    explain more about your problem and share a screenshot or code.
     
  24. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Hi all,
    I had the same problem in a 3d scene. When hit play, my player transform moved from (0, 0, 0) to (0, 0.5, 0) and even in play was not possible to bring back to 0 the Y axis.
    In my case the problem was the collider. Basically the ground collider and the player collider did not match, with the player collider just a 0.5 BELOW the ground. Once I fix it, I solved the problem.
    Hope it will help someone!
     
  25. Brumaires

    Brumaires

    Joined:
    Feb 24, 2022
    Posts:
    1
    I had the same issue with an animated object. I went back into Blender, set the mesh and the armature in the proper forward direction (Y Forward), then I did : "Ctrl + A, Rotation" to apply the rotation on the selected object. I applied the rotation on both the armature and mesh, then exported into Unity, problem solved
     
  26. Yavuz_Selim

    Yavuz_Selim

    Joined:
    Apr 16, 2021
    Posts:
    11
    In my experience, If an object from Blender doesn't have rig but have an animation clip data, this problem happening.

    I realised if object doesn't have an animator component, it is not moving anymore (whether I trigger an animation or not). Some fellas in here told that if they are not export animation, problem is not happening anymore. But what if you need to animate object and this problem is happening (well it is a very basic door in my project).

    With this problem, objects mostly moving around to 0, 0, 0. I guess the reason is, in Blender we mostly create and animate object around 0, 0, 0. And if they are not have armature and animate with this way; In Unity, somehow animator wants to play animation where it was animated in Blender. That's the reason it is moving to world's center I suppose.

    To solve that, I added a rig to door and animate bone instead of door itself. With that, door is not mysterious object waiting the center of the world anymore :D. It is now.. a door...
     
  27. nbogart

    nbogart

    Joined:
    Apr 3, 2022
    Posts:
    1
    So I've been having this issue with a Satallite model in a large space scene I'm working in. I tried the main camera clipping plane, the dolly cam clipping planes and nothing helped.

    I had thought the model was in fact just invisible, not realizing it was actually changing position. Mind you, I have a Dolly Cam that is animated and the Satallite is also animated. If you look into the Animator for the model that you're not seeing (If there's an animation), make sure to select "Apply Root Motion", this is what moves the object automatically using it's root motion from the animations.

    Not sure how much this helps here, hopefully it helps someone!