Hello everybody,
I am making a MOBA game and i have some skills. but the collision detection on the skills wont work.
The skill haves this code:
using UnityEngine;
using System.Collections;
public class Skull_Skill_01_Script : MonoBehaviour {
public int CoolDownTime;
public int Demage;
public GameObject Parent;
public GameObject ColliderFolower;
public GameObject[] ExploDestoy;
public Transform SpawnPos;
void Start (){
//GameObject ColliderFollower = Instantiate (ColliderFolower, this.gameObject.transform.position, this.gameObject.transform.rotation) as GameObject;
//ColliderFollower.GetComponent<Skill_Collider_Animated> ().SkillObjectTrans = this.gameObject.transform;
//ColliderFollower.GetComponent<Attack_Demage> ().Demage = 500;
}
void Update (){
transform.Translate(Vector3.forward * 25 * Time.deltaTime);
}
public void DestroySkill(){
GameObject Explo = Instantiate (ExploDestoy[0], SpawnPos.position, this.gameObject.transform.rotation) as GameObject;
Explo.gameObject.GetComponent<ParticleEmitter> ().Emit ();
GameObject Explo2 = Instantiate (ExploDestoy[1], SpawnPos.position, ExploDestoy[1].transform.rotation) as GameObject;
Explo2.gameObject.GetComponent<ParticleEmitter> ().Emit ();
Destroy (this.gameObject);
}
public void ExtraEffect (){
GameObject Explo = Instantiate (ExploDestoy[0], SpawnPos.position, this.gameObject.transform.rotation) as GameObject;
Explo.gameObject.GetComponent<ParticleEmitter> ().Emit ();
}
}
the skills has: Sphere Collider, Rigidbody (non-kinematic)
The character that sould detect the Collision has: Character Controller, Rigidbody.
and this code for collision Detections:
public void OnCollisionEnter(Collision col){
print ("Name is" + col.gameObject.name.ToString());
if (this.gameObject.tag == "Player_Team1") {
if(col.gameObject.tag == "Team2Attack" && this.gameObject.GetPhotonView().isMine){
int DemageDone = col.gameObject.GetComponent<Attack_Demage>().Demage;
this.gameObject.GetPhotonView().RPC("HitByEnemy", PhotonTargets.AllViaServer, DemageDone);
print("This is " + col.gameObject.name);
}
} else {
if(col.gameObject.tag == "Team1Attack" && this.gameObject.GetPhotonView().isMine){
int DemageDone = col.gameObject.GetComponent<Attack_Demage>().Demage;
this.gameObject.GetPhotonView().RPC("HitByEnemy", PhotonTargets.AllViaServer, DemageDone);
print("This is " + col.gameObject.name);
}
}
}
why doesnt this work??
plz help me
Greethings,
Vince Kieft