Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

NEED HELP WITH WEAPON SWITCH SYNC

$
0
0
hi, i am still new to photon networking, and i am having trouble with weapon switch. i want the weapon switch to update to the other clients.

here's my code for weapon switch. i dont know where to start XD

public int selectWeapon = 0;

void Start()
{

SelectWeapon();

}



void Update()
{
SelectWeapon();
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
if (selectWeapon >= transform.childCount - 1)

selectWeapon = 0;

else

selectWeapon++;
}

if (Input.GetAxis("Mouse ScrollWheel") < 0f)
{
if (selectWeapon <= 0)

selectWeapon = transform.childCount - 1;

else

selectWeapon--;
}

if (Input.GetKeyDown(KeyCode.Alpha1))
{
selectWeapon = 0;

}

if (Input.GetKeyDown(KeyCode.Alpha2))
{
selectWeapon = 1;

}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
selectWeapon = 2;

}


}



public void SelectWeapon()
{
int i = 0;
foreach (Transform weapon in transform)
{
if (i == selectWeapon)
weapon.gameObject.SetActive(true);
else

weapon.gameObject.SetActive(false);

i++;
}

}

Viewing all articles
Browse latest Browse all 15755

Trending Articles