private void Start() { characterAnimator = GetComponent <Animator>(); layerMask = 1 << LayerMaskIndex; weaponData = new WeaponDataObject(weapon); //weapon = ScriptableObject.Instantiate<WeaponScript>(weapon); }
public void OnAgentHited(WeaponDataObject weapon, GameObject agentHited, Vector3 hitPoint) { // O teste de munição não deve ser mais feito aqui no Manager, pois cada arma possui sua especificidade if (agentHited.CompareTag("Hitable")) { GameObject spark = Instantiate(weapon.particle); spark.transform.position = hitPoint; spark.transform.LookAt(agentHited.transform); Destroy(spark, spark.GetComponent <ParticleSystem>().main.duration); if (agentHited.GetComponent <Animator>()) { agentHited.GetComponent <Animator>().SetTrigger("Hit"); } if (agentHited.GetComponent <AgentData>()) { agentHited.GetComponent <AgentData>().life -= weapon.damage; if (agentHited.GetComponent <AgentData>().life <= 0) { agentHited.GetComponent <Animator>().SetTrigger("Dead"); Destroy(agentHited, 5); } } } }