- Home /
Instantiated over the client side by a photonviewed object?
Well, I have made a flamethrower which is observed by a photonview. The character which holds the rifle (Which instantiated the rifle) sends if it shoots the rifle and recieves other players info of shooting hte rifle or not. Now, for some reason the bullet which is being instantiated from the observed rifle (In this case the flames from the flamethrower) Will show collision for the player which shot them and wont provide collision for the other player who sees the flame.. It just passes through the player who is being shot at for him and for the player who shoots it collides. The bullets are not being observed by any network view (Any photon viewer or whatever) and are instantiated by the regular instantiate and not by a PhotonNetwork.Instantiate();
Why is this happening if both clients are getting clientside instantiated bullets and theres collision only for the one who shot them?!?
Heres the BULLET SCRIPT:
using UnityEngine;
using System.Collections;
public class bullet_script : MonoBehaviour {
public GameObject playerOwn;
public float speed=50;
public GameObject me;
public float timed=5;
public int dmgvalue=5;
void Update()
{
transform.position+=transform.TransformDirection(0,1,0)*Time.deltaTime*speed;
if(timed>0)
{
timed-=1*Time.deltaTime;
}
else
{
Destroy (me);
}
}
void OnTriggerStay(Collider victim)
{
print ("crap?");
//if(victim.gameObject!=playerOwn)
//{
GameObject grave;
if(victim.gameObject.tag=="Player")
{
print ("isplayer!");
grave=(GameObject)Resources.Load("Collidedblood");
victim.gameObject.GetComponent<player_combat>().Wound(dmgvalue);
}
else if(victim.gameObject.tag=="Wood")
{
grave=(GameObject)Resources.Load("Collidedwood");
}
else
grave=(GameObject)Resources.Load("Collidedust");
Instantiate (grave,transform.position,transform.rotation);
Destroy (me);
//}
}
}
PLEASE, help me, this problem bugs me for two weeks! :(
Answer by benk0913 · Jan 30, 2013 at 01:14 PM
PROBLEM SOLVED - Had to put a rigidbody on the bullet. :)