Написал небольшой скрипт на вылет префаба по нажатию ЛКМ, но при компиляции вылазит ошибка что у меня нет доступа пользоваться скриптом photonView (Так прочитал).
Искал в гугле, но никто не сталкивался с подобной проблемой.
Вот код.
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class prefabinst : MonoBehaviour
{
public GameObject bullet;
public float force;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (bullet)
{
if (photonView.isMine)
{
instaBullet();
}
}
}
}
void instaBullet()
{
GameObject go = Instantiate(bullet, transform.position, transform.rotation) as GameObject;
go.rigidbody.AddForce(transform.forward * force, ForceMode.Impulse);
}
[RPC]
void Fire(PhotonMessageInfo info)
{
if (info.sender.ID != PhotonNetwork.player.ID)
{
instaBullet();
}
}
}
using System.Collections;
public class prefabinst : MonoBehaviour
{
public GameObject bullet;
public float force;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (bullet)
{
if (photonView.isMine)
{
instaBullet();
}
}
}
}
void instaBullet()
{
GameObject go = Instantiate(bullet, transform.position, transform.rotation) as GameObject;
go.rigidbody.AddForce(transform.forward * force, ForceMode.Impulse);
}
[RPC]
void Fire(PhotonMessageInfo info)
{
if (info.sender.ID != PhotonNetwork.player.ID)
{
instaBullet();
}
}
}
Ошибка
Assets/Scripts/prefabinst.cs(27,32): error CS0120: An object reference is required to access non-static member `photonView.isMine'