void OnTriggerEnter(Collider col) { string s = col.gameObject.name; // name of the collider if (s.StartsWith("attack")) { canbeattack = true; attackarea = col.gameObject; } if (s.StartsWith("projectile")) { ProjectileAcclerate projacc = col.GetComponent <ProjectileAcclerate>(); if (projacc.owner != owner) { Destroy(col.gameObject); if (projacc.type >= type) { // health got decreased by 50 if toon got shot by projectile // (only toon of same or higher type can do damage) health -= 50; } } } }
public void CmdAttack(Vector3 hit) { sltpm.canattack = false; // sltpm.moveto = hit; GameObject col = (GameObject)Instantiate(projectile, sltpm.GetTransform().position + transform.up * 1.0f, Quaternion.identity); ProjectileAcclerate projacc = col.GetComponent <ProjectileAcclerate>(); projacc.owner = pname; projacc.type = sltpm.type; col.transform.LookAt(hit); NetworkServer.Spawn(col); }