PhotonNetwork OnParticleCollision(GameObject Other)

Hello all, I've been having a blast using photon networking and have nearly finished my game. A battle royale game similar to PUB-G but with a twist (ed metal) 8P, its vehicles! I have made it pretty far and I am on the final stages of tweaking weapons. I was using Ray Casting but decided to go with particles as I like the more realistic feel they give. Currently OnParticleCollision is working but when I try to get the name of the particle so I am able to properly set the damage float according to which particle hit it doesn't return the particles name. Here is the code I am using. Hope you can help!

this is my firing script which works properly.




void OnParticleCollision(GameObject other)
{
Transform hitTrans;
hitTrans = other.gameObject.transform;
if(hitTrans.gameObject.name == "Flame")
{
this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, sideDamage);
}
if (hitTrans != null)
{
if (hitTrans.name == "Flame")
{
this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, sideDamage);
}
}

if (other.name == "Fire" && view.isMine)
{
this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, AtomBombDamage);
}
if (other.name == "Flame" && view.isMine)
{
this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, sideDamage);
}
if(other.transform.name.ToString() == "Flame")
{
this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, sideDamage);
}

Comments

  • The code shows several ways of doing the same thing, so its kinda messy, sorry!!
  • Solved it. Here's my solution. Very simple. Didn't expect it to be as simple.
    Instead of comparing the name i instead check the tag of the particle emitter.

    void OnParticleCollision(GameObject other)
    {
    Transform hitTrans;
    hitTrans = other.gameObject.transform;

    if (hitTrans.gameObject.tag == "Flame")
    {
    this.GetComponent().RPC("TakeDamage", PhotonTargets.AllBuffered, sideDamage);
    }
    }
Sign In or Register to comment.