Search Issue Tracker

Duplicate

Votes

13

Found in

2017.2.0f3

Issue ID

960171

Regression

No

Incorrect transform position in Awake method of an instantiated prefab

Scripting

-

-

Priority: 3Not yet prioritized for a release

-

Severity: 3Secondary functionality broken

To reproduce:
1. Open attached Unity project "New Unity Project.zip"
2. Open "Scene" scene
3. Go into Play mode
4. Input letter "s" (it instantiates an instance of the prefab)
5. Observe the console

Expected result: prefab instance's position in the "TestObject" script's Awake method should be its actual position in the scene, which, in this case, is (1.0,2.0,3.0)
Actual result: prefab instance's position in the "TestObject" script's Awake method is the original prefab's position.

Reproduced on:5.6.3p4, 2017.1.0p2, 2017.2.0f3, 2017.3.0b5

Comments (5)

  1. 0e34cac96faf280850d9858607c3c57e?d=mm

    shadiradio

    Dec 06, 2017 17:00

    This is a definite showstopper, especially for an existing larger project. Moving things to Start() isn't a solution as people discussed, because of the large number of timing issues throughout the whole project.

    If Unity made a game in parallel to the editor, they would realize that their game was completely broken before releasing the patches. Do they test each patch release with example projects? This bug causes all kinds of issues on instantiation / tracking / positioning. I really hope a fix for 5.6 is imminent.

  2. B4f6543bd8fed4985c849d6b5b13afd7?d=mm

    Lad-Ty

    Dec 01, 2017 13:00

    Now when I want to work with spawning/despawning of this sort of projectiles (that do care about their initial position for various reasons), I have to call the same code in Start (for the first spawn/instantiations) and in OnEnable (for future spawning)... So yes, it can be worked around, but is messing up with the logic of what to initialize where quite a bit

  3. B4f6543bd8fed4985c849d6b5b13afd7?d=mm

    Lad-Ty

    Dec 01, 2017 12:09

    I would really like to give this issue my 9 other votes, since it's really game breaking, you cannot do any initialization properly in Awake on OnEnable. This bug is seriously horrifying I must say, I cannot believe that there's no outrage about it in the comments here.
    When you instantiate an object (a special type of projectile), you often want to register its starting position in onEnable in your 'projectile' component for example. But as is right now, you cannot do anything really. Well, you can do what you'd like in Start instead, but then you are screwed with spawning/despawning technique and you can only Instantiate/Destroy instead. Anyway, Awake and OnEnable are totaly useless for this purpose right now. And here I thought jumping to 2017.2 should be safe since 2017 is out for so long.

  4. 87e0eba21f7738e45f7a27f31eaf57f1?d=mm

    text23d

    Nov 30, 2017 16:24

    it seems I had similar error. I instantiated trolls/enemies, but they all appeared in one place ;-( but after some time, one buy one, they start "jumping out" of their position.
    I fixed this by first deactivating navmeshagent component in prefab, and then activating it in script.
    still, probably there is some issue with it as i'm getting 'SetDestination" (or Resume) can only be called on an active agent that has been placed on a NavMesh'

  5. F7dd45640ced2bc8b5c72357650d18fd?d=mm

    dvoidis

    Oct 31, 2017 10:17

    PLEASE FIX! :D , im still on an old beta because of this bug =(

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.