Синтаксис:
Используется csharp
private PhotonView view;
private GameObject Key01;
[SerializeField] private AudioClip audioPickupKey;
[SerializeField] private Camera goCamera;
private AudioSource audio_p;
public bool PickupKey01;
private void Awake()
{
view = GetComponent<PhotonView>();
if (view.IsMine)
{
Key01 = GameObject.FindGameObjectWithTag("Key01");
audio_p = GetComponent<AudioSource>();
}
}
void Update()
{
if (view.IsMine)
{
RaycastHit hit;
if (Physics.Raycast(goCamera.ScreenPointToRay(Input.mousePosition), out hit))
{
GameObject obj = hit.collider.gameObject;
if (obj == Key01 && Vector3.Distance(transform.position, Key01.transform.position) < 5)
{
if (Input.GetKeyDown(KeyCode.E))
{
audio_p.PlayOneShot(audioPickupKey);
PhotonNetwork.Destroy(Key01.GetPhotonView());
PickupKey01 = true;
}
}
}
}
}
private GameObject Key01;
[SerializeField] private AudioClip audioPickupKey;
[SerializeField] private Camera goCamera;
private AudioSource audio_p;
public bool PickupKey01;
private void Awake()
{
view = GetComponent<PhotonView>();
if (view.IsMine)
{
Key01 = GameObject.FindGameObjectWithTag("Key01");
audio_p = GetComponent<AudioSource>();
}
}
void Update()
{
if (view.IsMine)
{
RaycastHit hit;
if (Physics.Raycast(goCamera.ScreenPointToRay(Input.mousePosition), out hit))
{
GameObject obj = hit.collider.gameObject;
if (obj == Key01 && Vector3.Distance(transform.position, Key01.transform.position) < 5)
{
if (Input.GetKeyDown(KeyCode.E))
{
audio_p.PlayOneShot(audioPickupKey);
PhotonNetwork.Destroy(Key01.GetPhotonView());
PickupKey01 = true;
}
}
}
}
}