
as you can see I am shooting up on my main screen it shows bullets are going up and thats true ,
but on the other screen (other players) see the bullet going different direction.
Related Codes :
private void Update()
{
HandleShooting();
}
void HandleShooting()
{
if (Input.GetMouseButton(0))
{
if(Time.time > shootingTimer)
{
shootingTimer = Time.time + shootingTimerLimit;
//animate muzzle flash
shootinhAnimation.SetTrigger(TagManager.SHOOT_ANIMATION_PARAMETER);
//bullet shoot
CreateBullet();
}
}
}
private void CreateBullet()
{
// playerWeaponManager.Shoot(bulletSpwantPos.position);
if (!pv.IsMine)
{
return;
}
else
{
pv.RPC("Shoot", RpcTarget.All,bulletSpwantPos.position);
}
}
Function that instantiate the bullet
[PunRPC]
public void Shoot(Vector3 spawnPos)
{
targetPos = mainCam.ScreenToWorldPoint(Input.mousePosition);
bulletSpawnPosition = new Vector2(spawnPos.x , spawnPos.y);
direction = (targetPos - bulletSpawnPosition).normalized;
bulletRotation = Quaternion.Euler(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf. Rad2Deg);
if (direction.x < -1 && direction.y > 0)
{
BulletPool.instance.FireBullet(weaponIndex, bulletSpawnPostLast[2].position, bulletRotation, direction);
}
if (direction.x < 1 && direction.y < 1)
{
BulletPool.instance.FireBullet(weaponIndex, bulletSpawnPostLast[1].position, bulletRotation, direction);
}
}