Applying damage to different sections of a game object

Hey Guys,

In my game, I have a spaceship, and I want it to take damage on the specific area of the ship that gets hit. I should mention that I’m using AddForce to move my ship forward and AddTorque to rotate it.

I figured a separate collider for each section would be the way to go, but does each collider have to have its own rigidbody? Otherwise, it’s a compound collider, which would act like a single collider, causing the entire ship to take the damage.

If I do need a rigidbody for each collider, how do I get several rigidbodies to move together in a group? Is there a way to parent a group of rigidbodies to one rigidbody that does the moving? I’ve already tried having a rigidbody added to each empty game object that I have a collider on, but when the ship moves forward, it leaves those gameobjects behind.

Does anyone have any suggestions on how to approach this issue?

Adding seperate collider with trigger on is the right way to go. You don’t need to add rigidbody. But bullet should have a rigidbody or trigger won’t be triggered.

You can try to write a simple HitDetection script to each part of the ship, e.g. LeftWing, RightWing, Shield, etc. and assign an id to each part, then OnCollisionEnter send this id to your MainShip script.

using UnityEngine;
using System.Collections;

public class ShipPartHit : MonoBehaviour {

	public enum ShipPart{
		leftWing, rightWing, bridge
	}

	public ShipPart part;

	void OnCollisionEnter(){
		//shipScript.TakeDamageOn(part);
	}

}