- Home /
Question by
warlord100 · Oct 09, 2016 at 07:31 PM ·
networkinginstantiatemultiplayerfpsprojectile
Multiplayer projectiles
Having issues shooting projectiles, the host works perfectly, while clients shoot and the projectile will sit in front of the player, would be extremely grateful for any insight..
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
if (!selectedProjectileButton.overButton())
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100f))
{
Shoot();
}
}
}
}
[Client]
void Shoot()
{
CmdShoot(transform.position + (transform.forward / 2) + (transform.up / 2), transform.rotation);
}
[Command]
void CmdShoot(Vector3 spawnpos, Quaternion spawnrot)
{
GameObject projectile = (GameObject)Instantiate(projectiles[currentProjectile], spawnPosition.position, Quaternion.identity);
projectile.transform.LookAt(hit.point);
projectile.GetComponent<Rigidbody>().AddForce(projectile.transform.forward * speed);
projectile.GetComponent<ProjectileScript>().impactNormal = hit.normal;
NetworkServer.SpawnWithClientAuthority(projectile, connectionToClient);
}
projectilenot.jpg
(400.4 kB)
Comment
Your answer
Follow this Question
Related Questions
Photon Networking Instantiating Problem 0 Answers
Unity networking tutorial? 6 Answers
Network.Instatiate Problem 0 Answers
Frames Per Second Cost from Multiplayer? 1 Answer
How do you access a photonNetwork.Instantiate Object 2 Answers