Hello,
I created a FPS which works fine in single player. However since I made it in multiplayer, the shoot doesn’t work. In single Player, I made this :
private void Fire()
{
fireRate = 0.36f;
nextFire = Time.time + fireRate;
Rigidbody balle;
i++;
Quaternion qua = new Quaternion(0, 0, 0, 0);
balle = Instantiate(balleCasting, transform.position, qua);
balle.velocity = transform.TransformDirection(Vector3.right) * ejectSpeed;
balle.isKinematic = false;
balle.transform.rotation = new Quaternion(0, 0, 0, 0);
balle.name = "Bullet " + I;
shoot.Play();
}
balle is the new bullet (which will be instantiate).
ballecasting is the bullet which is in my gun.
This script was placed on my gun (which is in my character).
Now, because I’m in multiplayer, I can’t use this script because I can’t know if it is the local Player who is shooting or if it is another player (because the networkIdentity is placed on the root of my character and not on my gun). So I placed this script in the player’s root (in order to be able to check the networkIdentity), this is the script :
private void Fire()
{
fireRate = 0.36f;
nextFire = Time.time + fireRate;
Rigidbody balle;
i++;
balle = Instantiate(balleCasting, BulletPos.transform.position, Quaternion.identity);
balle.velocity = transform.TransformDirection(Vector3.forward) * ejectSpeed;
balle.isKinematic = false;
balle.name = "Bullet " + i;
shoot.Play();
}
BulletPos is a gameObject which represent the position of the gun (and BalleCasting is the same thing as the first script).
Finally this script DOESN’T work well : my bullet is shot but it just go in front of my character. So if I look in the sky, my bullet doesn’t go in the sky, it only goes straight forwards.
Can someone help me please 0_0.