Quantcast
Channel: Answers for "Unity freezes when OnTriggerEnter occurs"
Viewing all articles
Browse latest Browse all 6

Answer by ThomasMarsh

$
0
0
I managed to fix my own issue by modifying the code inside the OnTriggerEnter so that the object that collides with the trigger is checked first, and then the cooldown and meshrenderer are checked in an if statement nested one level below. function OnTriggerEnter (other: Collider){ if(other.gameObject == playerHitBox){ if(!hitCoolDown && meshObject.GetComponent(SkinnedMeshRenderer).enabled){ playerState.Damage(damageDone); hitCoolDown = true; } } } I also all the trigger events occur in a separate layer because I have other colliders on both the enemy and the player than the ones I use here. Now everything works perfectly. Thank you all for all the help.

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>