Photonview.isMine moves other character
Hello,
I am new in Photon and when i make two builds using teleport with a raycast from right controller the players who teleports is the other player and not mine. This is the code. photonView variable has assigned the photonView component
This is the code. I use my own teleport system
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using Photon.Pun;
public class Teleport : MonoBehaviour
{
public XRController rightHandDevice;
public LayerMask hitLayermask;
public PhotonView photonView;
bool lastTriggerValue;
bool triggerValue;
private void Start()
{
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit();
if(InputManager.Instance!=null && photonView.AmOwner)
{
triggerValue = InputManager.Instance.triggerHand(rightHandDevice);
if (triggerValue && triggerValue != lastTriggerValue)
{
if (Physics.Raycast(rightHandDevice.transform.position, rightHandDevice.transform.forward, out RaycastHit hit, Mathf.Infinity, hitLayermask))
{
Debug.LogError("Teleport");
transform.position = hit.point;
}
}
lastTriggerValue = triggerValue;
}
}
}
This is my setup in Unity
Answers
-
I replied in Discord, if I recall correctly. The question is who instantiated the networked objects and which one is "yours" (IsMine being true)...
0