Homing to target object problem.

I want to hit my homing missile exactly enemy’s center place and want to collider it as it hit enemy’s skin.

I use function of OnCollisionEnter, like this,

function OnCollisionEnter(hit : Collision) // When the bullet hits something
{
	if (hit.transform.tag == "enemy") { // If it's the enemy
		hit.gameObject.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); // Hurt it
		 
		Instantiate(deathParticles, transform.position, transform.rotation); // Create death particles
		Destroy(this.gameObject);
	}
}

But problem is, if enemy is some complicated prefab and has many spines and joints, there is many factor in just 1 character like fbx file.

Anyway, if I set that enemy character’s Tag as [enemy], missile goes to enemy’s foot’s center location, not body’s center. And missile does some rotate action at there and then destroyed itself.

This seems ridiculous and don’t know why.

The script you’ve posted is not the one you needed to for your problem. You should have posted the script that tells it where and how to move (the “homing” part of it). Still, it seems to me like you’ve set the transform.position of your enemy as it’s “center place”. instead, use one of these:

  1. (transform.position+Vector3.up*variable) where the variable is the distance from the feet of the character to it’s body center.

  2. if it’s a rigidbody, Rigidbody.centerOfMass

  3. if it’s a sphere, box or capsule collider, use .center

Thanks.

But is there no option of transform’s center?

+Vector3.up*1.5 is not the best in case of small enemy.