Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition on suicide #20

Open
kazimuth opened this issue Feb 7, 2025 · 1 comment
Open

Race condition on suicide #20

kazimuth opened this issue Feb 7, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@kazimuth
Copy link
Contributor

kazimuth commented Feb 7, 2025

sometimes you get

MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Transform.get_position () (at <779cc116a5954f1c9b92496e62345641>:0)
EntityController+<DespawnCoroutine>d__11.MoveNext () (at Assets/Scripts/EntityController.cs:70)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <779cc116a5954f1c9b92496e62345641>:0)
@kazimuth kazimuth self-assigned this Feb 7, 2025
@kazimuth kazimuth added the bug Something isn't working label Feb 7, 2025
@WeslomPo
Copy link
Contributor

WeslomPo commented Mar 7, 2025

transform.position = Vector3.Lerp(startPosition, targetTransform.position, t);
Maybe problem not in transform.position but in a targetTransform.position.

Imagine, when coroutine starts targetTransform is already dying, and when it was dead, there will be NRE, because food that was being consumed is still alive. Possible solution is just remember position of targetTransform before starting to wait. Or pooling objects (then there never be nre).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants