I’m creating a melee system that works but I need to redo it so I can use it online if it ever gets there. What I think I need to do is, on the monster, on triggerenter, get the player thats doing the attack and check a variable on him. Say, isAttacking = true. Then if its true do the rest. I’m wondering is this possible? Heres my example code atm that i’m trying to convert to that idea.
—Attached to enemy—
static var swordReady : boolean = false;
function Start () {
}
function Update () {
}
function OnTriggerEnter (col : Collider)
{
if(swordReady == true)
{
if(col.tag == "Weapon")
{
EnemyLogic.Enemy_Health -= 25;
print(EnemyLogic.Enemy_Health);
swordReady = false;
}
}
}
---Attached to Player---
#pragma strict
function Start () {
}
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
Enemy_Attacked.swordReady = true;
animation.Play("Attack");
animation["Attack"].wrapMode = WrapMode.Once;
}
}