So I have created this movement script and have attached it to the body of the player. I have not made a proper model yet in Blender however I decided to create a basic model (with a GameObject) with a head hit box using a GameObject.
So is there away of using my Movement Script attached to the body of the player, and monitor the Collider of the Hit Box Object?
This is what I’ve guessed so far (written in C#):
private GameObject playerHead;
playerHead = new GameObject("Player_Head");
playerHead.AddComponent("BoxCollider");
I’m not sure why your question was downvoted, but of course you can do it. You’ll need another script to do it though. OnTriggerEnter only gets called on the object that the collider is attached to, so create a script that just monitors for trigger enters and informs the Movement Script. It would look something like this:
public class Movement : MonoBehaviour
{
public void TriggerEntered(Collider triggeredCollider, Collider triggeringCollider)
{
// do something
}
}
public class OnTriggerEnterMonitor : MonoBehaviour
{
public Movement movementScript;
void OnTriggerEnter(Collider other)
{
movementScript.TriggerEntered(this, other);
}
}