im using photon network, and im bashing my head up against the wall trying to figure out how to do this.
i want it so that when the object collides with another, it reads the viewid of the object it hit and i can deduct health points. reason why i need the view id, is because it belongs to another player. im extremely confused. if you can give me an example of a better way to get this done, please dont hesitate to show me :).
using UnityEngine;
using System.Collections;
public class fireballexplosion : Photon.MonoBehaviour {
float lifespan = 3.0f;
// Use this for initialization
void Start () {
//note: change for other maps ----
GameObject _map1 = GameObject.Find ("Map1");
GameObject _warrior = GameObject.Find ("6102024(Clone)");
GameObject _Mage = GameObject.Find ("MagePlayer(Clone)");
Physics.IgnoreCollision (_map1.collider, collider);
//Physics.IgnoreCollision (_warrior.collider, collider);
//Physics.IgnoreCollision (_Mage.collider, collider);
}
// Update is called once per frame
void Update () {
lifespan -= Time.deltaTime;
if(lifespan <- 0) {
Explode();
}
}
[RPC] void OnCollisionEnter (Collision collision) {
//Destroy (GameObject);
if(collision.gameObject){
//this is all failed attempts to try to do this..
print("This collider collided with: " + pView);
foreach (ContactPoint contact in collision.contacts) {
print(contact.thisCollider.name + " hit " + contact.otherCollider);
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
lifespan = 0.25f;
//Destroy (gameObject);
}
}
void Explode () {
Destroy (gameObject);
}
}