Search Issue Tracker

By Design

Unknown (hidden) 2020.3.X, 2021.3.X, 2022.1.X, 2022.2.X, 2023.1.X

Votes

0

Found in

2020.3.41f1

2021.3.13f1

2022.1.22f1

2022.2.0b14

2023.1.0a18

Issue ID

UUM-18846

Regression

No

Animator Integer state variable gets nulled when playing in builds

--

-

Reproduction steps:
1. Open the user’s attached project
2. Build And Run the project
3. In the Player click the “Play“ button and wait for the animation to play
4. When the animation stops point the mouse at an enemy and right-click

Expected result: The Player does not freeze
Actual result: The Player freezes

Reproducible with: 2020.3.41f1, 2021.3.13f1, 2022.1.22f1, 2022.2.0b14, 2023.1.0a18

Reproduced on: Windows 10 Pro

Notes:
1. Not reproducible in the Editor
2. In the Standalone build after shooting the first enemy, bullet collision no longer works and the animation starts to loop
3. In the WebGL build the Player freezes after shooting an enemy and an error pop-up appears

  1. Resolution Note:

    The error in WebGL and the in the standalone build (if you look at the development console, you'll see NullReferenceException being thrown) came from a null Animator that was retrieved from `human.GetComponent<Animator>()`.

    Calling `GameObject.Find(hit.collider.name)` is a very unsafe way to retrieve a GameObject. In this case, both the root character game object and the nested mesh game object had the same name. This function would retrieve different game objects in the editor and standalone builds.

    If you replace the `GameObject.Find` line with `human = hit.collider.gameObject;`, everything works correctly.

Add comment

Log in to post comment

All about bugs

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