Search Unity

Strange Instantiate behaviour in 2017.1.1p2

Discussion in 'Scripting' started by weeksy, Sep 17, 2017.

  1. weeksy

    weeksy

    Joined:
    Dec 9, 2013
    Posts:
    39
    I updated to 2017.1.1p2 yesterday and I'm seeing some weird behaviour with Instantiate. If I instantiate a prefab at a set location, when I check the location in Awake on a script attached to the prefab I get the wrong value. So:

    GameObject.Instantiate(m_Prefab, new Vector3(123, 456, 789), Quaternion.identity);

    Then in the prefab setup:

    void Awake()
    {
    Debug.Log("Awake: " + transform.position);
    }
    void Start()
    {
    Debug.Log("Start: " + transform.position);
    }

    I get this:
    Awake: (0.0, 0.0, 0.0)
    Start: (123.0, 456.0, 789.0)

    I have tried this in a fresh new project and it always happens. I came from 5.6.2p2 and I've checked 2017.1.0p5 and this works fine (same test project). Anyone else seeing this?

    thanks
     
    Last edited: Sep 17, 2017
    Xepherys likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    Please file a bug report so we can investigate.
     
  3. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    103
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    Yeah I think this is from a fix we made recently. I know the change that caused it(it was me :(). A dev is looking Into it.
     
    Baste likes this.
  5. weeksy

    weeksy

    Joined:
    Dec 9, 2013
    Posts:
    39
    Just checked it with 2017.1.2f1, still happens. Any idea on when a fix will be in? We spawn objects in Awake calls using position, so this is basically a show stopper for us.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    It's in the queue to go into the next patch release.
     
  7. weeksy

    weeksy

    Joined:
    Dec 9, 2013
    Posts:
    39
    Great. Thanks Karl.
     
  8. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    103
    Does anybody know if this is fixed in 2017.1.2p1?
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    No the fix is not out yet. It got held back by some failing tests. I am hoping to have it in the next patch.
     
  10. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    103
    Thanks Karl!

    I'll ask again when p2 comes out :)

    - David L
     
  11. Lad-Ty

    Lad-Ty

    Joined:
    May 7, 2013
    Posts:
    26
    It seems this is still the issue even in 2017.2, even though the previously linked bugreport is marked as resolved?
    https://issuetracker.unity3d.com/is...ion-in-awake-method-of-an-instantiated-prefab

    I encountered it today after upgrading from 5.6 to 2017.2... In the place I am dealing with it it is sort of solvable by delaying the functionality to the Start method, but I must say it is not elegant/does feel very wrong, and I'm not sure what other scripts might suffer from it that are used somewhere further in the game where I did not yet test.
     
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    This is fixed in 2017.2.0p1+ https://unity3d.com/unity/qa/patch-releases?version=2017.2
     
    ThermalFusion likes this.
  13. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Any idea if this is going to be fixed in a 5.6.4 patch soon? It's still broken in 5.6.4p4.
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    Its currently in the queue to go in. It should be in the 5.6.5 release
     
  15. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Thanks very much for the update Karl! :)
    Is there a timetable / known update window for 5.6.5?
     
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    Around the 15th December. Subject to change though if we find any issues during testing.
     
  17. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Fantastic, thanks for the info Karl. :)
     
    karl_jones likes this.
  18. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Crossing my fingers. :)
     
  19. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Any ETA on this fix/update? I've had a major content patch ready for a month, held up by this bug. I'm hoping to release it before the holiday sales.
     
    Last edited: Dec 21, 2017
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,761
    Its currently undergoing testing. Eta 20th Dec – 22nd Dec.
     
  21. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Is there a chance that the 5.6.5 drop will still make it today? I'm not sure how everyone is getting by for the past few months without being able to access transform.position inside Awake()... am I crazy?

    I know that a local workaround is to set the prefab or object's position before instantiating (even though this causes a lot of unnecessary version control changes), but is there a workaround for online/unet games? NetworkServer.Spawn() will have the incorrect transform.position in Awake() on clients.
     
  22. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
  23. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    75
    Actually on my first quick test, it appears to work properly locally. Karl - can you confirm that this is fixed in the latest 5.6.5 release, but is just missing from the release notes?
     
  24. -chris

    -chris

    Joined:
    Mar 1, 2012
    Posts:
    59
    Had position issues with 5.6.4p4, but things seem to be back to normal with 5.6.5f1 now.
     
  25. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    56
    When will this issue fixed? i got it in latest version 2017.3.1f1. not able to work on a project with a bug like this??
     
  26. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,713
    When I looked this up, it was fixed in b5 it said, for 2017.3.0.

    I just tested it on my copy of Unity to be sure, and it's giving the correct results.
    My version: 2017.3.1p2

    Patches here: https://unity3d.com/unity/qa/patch-releases
     
    -chris likes this.
  27. eurekaed

    eurekaed

    Joined:
    Jan 18, 2018
    Posts:
    5
    real? this not work in 2017.3.1p3
    WTF???

    void Awake()->this.transform.position = Vector3.one;
    void Awake()->Debug.Log(this.transform.position);
    Log->(0,0,0)

    It's humiliating!!!!
     
  28. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,423
    update to 2017.4, it is the LTS version and you should be on it if your using 2017.X
     
  29. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,713
    If you can create the bug in a small repo, file a bug report.
     
unityunity