Скрипт стрельбы:
Синтаксис:
Используется csharp
public void Shooting()
{
if (photonView.isMine) {
int damage=10;
RaycastHit hit;
Ray ray= Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit,400))
{
if (hit.transform.tag=="head")
{
hit.transform.GetComponent<PhotonView>().RPC("AddDamage", PhotonTargets.All, damage);
}
}
}
}
{
if (photonView.isMine) {
int damage=10;
RaycastHit hit;
Ray ray= Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit,400))
{
if (hit.transform.tag=="head")
{
hit.transform.GetComponent<PhotonView>().RPC("AddDamage", PhotonTargets.All, damage);
}
}
}
}
скрипт на триггере:
Синтаксис:
Используется csharp
[RPC]
public void AddDamage(int damage)
{
if (photonView.isMine) {
headHp -= damage;
if (headHp <= 0) {
gameObject.SetActive (false);
}
}
}
public void AddDamage(int damage)
{
if (photonView.isMine) {
headHp -= damage;
if (headHp <= 0) {
gameObject.SetActive (false);
}
}
}