Hi, when I fire with my player, the projectile will go towards where I exited the game window with my mouse for the other connected player. Probably something to do with using Camera.main.ScreenToWorldPoint()
like this when I fire:
if (photonView.isMine)
{
// normal fire
if (Input.GetButton("Fire1") && Time.time > nextFire && Time.timeScale == 1)
{
nextFire = Time.time + fireRate;
this.audio.Play();
Vector3 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3 transPos = transform.position;
Vector3 v3DirProjectile = target - transPos;
float angleProjectile = Mathf.Atan2(v3DirProjectile.y, v3DirProjectile.x) * Mathf.Rad2Deg;
Quaternion transRot = transform.rotation;
Vector3 angle = new Vector3(0f, 0f, angleProjectile);
// instantiate projectile
GameObject tempProjectile = PhotonNetwork.Instantiate(projectile.name,
new Vector3(transPos.x + 0.2f, transPos.y, transPos.z),
Quaternion.Euler(angle), 0) as GameObject;
}
}
Shouldn’t the projectile have the point of origin, angle and target as the player shooting? Thank you.