Hey why is it when my first player shoots the second player he shows him dieing but on the second players screen the projectile is just sat next to him and hes not dead and can kill the other player fine
script on the projectile
using UnityEngine;
using System.Collections;
public class Impactm : Photon.MonoBehaviour {
public int Life;
void Update()
{
Destroy(gameObject, Life);
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Tank")
{
gameObject.SetActive (false);
col.gameObject.SetActive (false);
}
}
}
tank script
using UnityEngine;
using System.Collections;
public class TankMovementM :Photon.MonoBehaviour {
//Movement
public int speed;
public int Turnspeed;
//Deafult gun
public Transform Launcher = null;
public float ProjectileSpeed;
public int Clip = 0;
public bool DefaultGun;
//MacchineGunShot
public bool MachineGun;
public Rigidbody MachineGunBullet = null;
public float MachineGunSpeed;
public int MClip = 0;
public Transform MBulletpos = null;
public float rateOfFire;
private float rateOfFireTimer = 0.0f;
public GameObject MText;
public Transform MTextLoc;
//Sounds and paricles
public GameObject Particle;
public GameObject Explode;
public AudioClip Bomb;
public AudioClip ExplodeSound;
public AudioClip Shotgun;
public AudioClip Pistol;
public Texture real;
public GameObject body;
void Start ()
{
if (photonView.isMine)
{
body.renderer.material.mainTexture = real;
}
DefaultGun = true;
MachineGun = false;
Time.timeScale = 1F;
cInput.SetKey("BlueTank Forward", "W");
cInput.SetKey("BlueTank Reverse", "S");
cInput.SetKey("BlueTank Turn Left", "A");
cInput.SetKey("BlueTank Turn Right", "D");
cInput.SetKey("BlueTank Shoot", "LeftControl");
}
void Update()
{
rateOfFireTimer += Time.deltaTime;
}
// Update is called once per frame
void FixedUpdate ()
{
//Movement
//foward
if (photonView.isMine)
{
if (cInput.GetKey("BlueTank Forward"))
{
transform.localPosition += transform.forward * speed * Time.deltaTime;
}
//Backwards
if (cInput.GetKey("BlueTank Reverse"))
{
transform.localPosition += -transform.forward * speed * Time.deltaTime;
}
//Rotate Left
if (cInput.GetKey("BlueTank Turn Left"))
{
transform.Rotate(0, -Turnspeed, 0, Space.Self);
}
//Rotate Right
if (cInput.GetKey("BlueTank Turn Right"))
{
transform.Rotate(0, Turnspeed, 0, Space.Self);
}
//Shooting
if (Clip == 5)
{
DefaultGun = false;
}
if (Clip > 5)
{
Clip = 5;
}
if (MClip == 10)
{
MachineGun = false;
Clip = Clip;
MClip = 0;
DefaultGun = true;
}
if (MClip > 10)
{
MClip = 10;
}
if (cInput.GetKeyDown("BlueTank Shoot"))
{
FireGun();
}
if (cInput.GetKey("BlueTank Shoot")&& rateOfFireTimer >= (1/rateOfFire))
{
FireMachineGun();
}
}
}
void FireGun()
{
if (DefaultGun == true)
{
Clip = Clip +1 ;
audio.PlayOneShot(Bomb);
GameObject part = Instantiate(Particle, Launcher.position, Launcher.rotation)as GameObject;
GameObject shot = PhotonNetwork.Instantiate("BulletM", Launcher.position, Launcher.rotation,0) as GameObject;
shot.rigidbody.AddForce(Launcher.forward * ProjectileSpeed );
Destroy (part, 1);
}
}
void FireMachineGun()
{
if (MachineGun == true)
{
Rigidbody shot = Instantiate(MachineGunBullet,MBulletpos.position, MBulletpos.rotation) as Rigidbody;
shot.AddForce(Launcher.forward * MachineGunSpeed);
audio.PlayOneShot(Pistol);
MClip = MClip +1 ;
rateOfFireTimer = 0.0f;
}
}
[RPC]
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Projectile")
{
GameObject part = Instantiate(Explode, transform.position, transform.rotation)as GameObject;
AudioSource.PlayClipAtPoint(ExplodeSound,transform.position);
Destroy (part, 2);
gameObject.SetActive (false);
}
if (col.gameObject.tag == "Tank")
{
GameObject part = Instantiate(Explode, transform.position, transform.rotation)as GameObject;
// PhotonNetwork.Destroy(this.gameObject);
Destroy (part, 2);
}
if (col.gameObject.tag == "Ammo")
{
audio.PlayOneShot(Shotgun);
Clip = 0;
DefaultGun = true;
col.gameObject.SetActive(false);
}
if (col.gameObject.tag == "MachineGun")
{
audio.PlayOneShot(Shotgun);
GameObject part = Instantiate(MText, new Vector3(-8, 0, 0),Quaternion.Euler(90, 0, 0))as GameObject;
DefaultGun = false;
MachineGun = true;
col.gameObject.SetActive(false);
}
if (col.gameObject.tag == "Time")
{
col.gameObject.SetActive(false);
Time.timeScale = 0.3F;
}
}
}