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
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 (7)
-
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.
-
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
-
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. -
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' -
dvoidis
Oct 31, 2017 10:17
PLEASE FIX! :D , im still on an old beta because of this bug =(
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "Missing or broken path ()" is shown when opening the "Open Recent Scene" dropdown on a newly created project
- Foveation is not applied to final Blit Passes when camera Post-Processing is disabled in URP & SRP
- Caret is not being offset when content on a GUISkin is offset
- [Android][Vulkan] Application crashes with out of memory when warming up a specific shader on some of the Adreno devices
- Unity Editor hangs on a fresh import when using "-CacheServerWaitForUploadCompletion" command line argument
This is a duplicate of issue #953068