- Home /
Bullet wont collide for the other player (PHOTON+UNITY)
Ive been working on a flamethrower as one of my weapons. Its a platform multiplayer online game. It is also working with photon. I am having a problem with the flames(and the other rifles bullets too). THe flames which the flamethrower shoots are being instantiated with PhotonNetwork.Instantiate... And they do collide with the player which instantiated them, and the other player is able to see them instantiated and their movement. But for some reason the player which instantiates them sees who they collide to and sees them collided but the other player which is shot at wont see the flames collided with himself or with the walls. The flames own their script of collision and movement and a photonView component.
What do I do to solve this issue?
Answer by benk0913 · Jan 30, 2013 at 01:14 PM
PROBLEM SOLVED - Had to put a rigidbody on the bullet. :)
Could you post your code pretty please? I am working on a similar game and i'm very stuck.
You want a basic shooting script that works and a bullet mover? (Be sure to compare how other tutorials show their versions so in the future you can tweak them more to your liking.)
Add to Empty Game Object and name it shoot or ShotSpawn, Just for organizing. (Also get your shot sound cause you will attach an Audio Source to it,
using UnityEngine;
using System.Collections;
using System;
public class Shoot : $$anonymous$$onoBehaviour
{
public GameObject bullet;
public float delayTime = 1;
private float counter = 0;
void Start()
{
}
void Update()
{
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse0) && counter > delayTime)
{
Instantiate(bullet, transform.position, transform.rotation);
GetComponent<AudioSource>().Play();
counter = 0;
}
counter += Time.deltaTime;
}
}
Put this one on the bullet itself in scene and then drag it back in you assets as a prefab with the script attached. It will destroy the clones after 6 seconds,
using UnityEngine;
using System.Collections;
public class $$anonymous$$oveBullet : $$anonymous$$onoBehaviour
{
public float speed = 20.0f;
// Use this for initialization
void Start()
{
}
Good luck.
// Update is called once per frame
void Update()
{
transform.Translate(0, 0, speed);
Destroy(this.gameObject, 6);
}
}
Remember, the Shoot Script goes on the Empty Game Object you rename Shoot, ShotSpawn or whatever and place in front of the point where the bullet comes out of (or Bolt, or Coconut or Egg, it does not matter what THE BULLET Object is called in this case).
You make the Bullet Itself and save it with the script in your assets,. You delete te bullet from the Scene where you build stuff. On the Shot Spawn point you drag the prefab object to the part where it says "bullet" on the Shoot Script,.
Looks like this as examples.
Your answer
Follow this Question
Related Questions
Photon Player resets to 0,0,0 0 Answers
Network two players collision 2 Answers
Instantiating random prefabs when the player passes through a trigger 1 Answer
photon Spawn 4 players in different positions 0 Answers
How can I get PhotonPlayer GameObject 0 Answers