And doing the same action will cause an error to occur.
Below is a code snippet of how i trigger the sprite swap.
reachAction is basically the one that does spriteRend.sprite = newSprite
MissingReferenceException: The object of type 'SpriteRenderer' 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.
TileScript.Remap () (at Assets/_Scripts/Tile/TileScript.cs:38)
TileManager.OnEnemyDeath (UnityEngine.Vector2Int obj) (at Assets/_Scripts/Managers/TileManager.cs:689)
EnemyManager.RemoveEnemy (EnemyScript es) (at Assets/_Scripts/Managers/EnemyManager.cs:169)
EnemyScript.TakeDamage (System.Int32 damage) (at Assets/_Scripts/Enemy/EnemyScript.cs:39)
EnemyManager.DamageEnemy (UnityEngine.Vector2Int point, System.Int32 v) (at Assets/_Scripts/Managers/EnemyManager.cs:153)
AttackManager+<>c__DisplayClass15_0.<Attack>b__0 () (at Assets/_Scripts/Attack/AttackManager.cs:87)
ProjectileManager+<>c__DisplayClass7_0.<ShootAt>b__0 () (at Assets/_Scripts/Managers/ProjectileManager.cs:33)
DG.Tweening.Tween.OnTweenCallback (DG.Tweening.TweenCallback callback, DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:302)
DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, System.Single toPosition, System.Int32 toCompletedLoops, DG.Tweening.Core.Enums.UpdateMode updateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:276)
DG.Tweening.Core.TweenManager.Update (DG.Tweening.UpdateType updateType, System.Single deltaTime, System.Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:490)
DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:74)
So i have a scene, that swaps a sprite when its attacked. On first scene, it works fine. But after doing
And doing the same action will cause an error to occur. Below is a code snippet of how i trigger the sprite swap.
reachAction
is basically the one that doesspriteRend.sprite = newSprite
Full log.