Hello. So, I have:
- Login scene, there I enter my Nickname and chose between Blue and Yellow capsule;
- Indestructible object Statics to keep my choice;
- Game scene with Blue and Yellow capsule game object (not prefabs) with scripts like this attached:
public class MouseMove1 : MonoBehaviour
{
bool bControlable;
RaycastHit hit;
Vector3 clPos;
Vector3 newDir;
public float rotSpeed = 2f;
public float mSpeed = 1f;
void Start()
{
bControlable = false;
if (GameObject.FindGameObjectWithTag("Statics").GetComponent<Statics>().obj1owner == PhotonNetwork.NickName)
{
bControlable = true;
}
}
void Update()
{
if (!bControlable)
{
return;
}
Debug.DrawRay(transform.position, transform.forward*10, Color.green, 0.2f);
Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(0)) {
if(Physics.Raycast(mRay, out hit))
{
clPos = hit.point;
}
}
mMove();
}
void mMove()
{
newDir = Vector3.RotateTowards(transform.forward, clPos, rotSpeed * Time.deltaTime, 0.0f);
transform.rotation = Quaternion.LookRotation(newDir);
transform.position = Vector3.MoveTowards(transform.position, clPos+Vector3.up, mSpeed*Time.deltaTime);
}
}
So, basically, I’m using PhotonNetwork.NickName to define, who controls which object.
Of course, i’ve attached PhotonView and PhotonTransformView on this capsules.
Problem is: guest player sees all changes on scene, but host can’t see guest player movements.
What’s the problem?