Collision Handling for a Fighting Game

Hey everyone!

I am currently developing an AI demo for a fighting game.

I wrote an OnTriggerEnter function that detects fists or kicks; however it detecs actions if and only if the character move.

For example, I kick the other character, and my character’s leg enters, and exits the collider but, OnTriggerEnter is not called in this scenario until I move my character.

How can I solve this problem?

Thank you!

Here is my code:

function OnTriggerEnter(collision : Collider)
{

	if( collision.gameObject.name == "AI_Arm" || collision.gameObject.name == "AI_Leg" )
	{
		Debug.Log("PLAYER HIT!");	
	}
}

P.S: I used other version of the "OnTrigger"s but, it remains same.

You might want to have a read over this article. In short, for the sake of optimisation rigidbodies that aren’t moving are considered “sleeping”, which helps performance however it can result in problems like this.

In order to avoid it, you can force your rigidbody to stay awake with

rigidbody.WakeUp();

Hopefully that fixes the problem