Canvas transform position problem

Options
I have a gameObject prefab (not player) and that script attached to it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;

namespace Photon.Pun.Game
{
public class PrefabScript : MonoBehaviourPunCallbacks
{

public PhotonView photonView;

void Start()
{

this.GetComponent<Transform>().SetParent(GameObject.Find("Canvas").GetComponent<RectTransform>());
gameObject.transform.Rotate(0, 0, -70 * Time.deltaTime);
gameObject.transform.localScale = new Vector3(70, 70, 70);
gameObject.transform.localPosition = new Vector3(0, 0, 0);
gameObject.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
gameObject.GetComponent<RectTransform>().anchorMax = new Vector2(1, 0);
gameObject.GetComponent<RectTransform>().pivot = new Vector2(1, 0);
gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector3(0, 0, 0);
}

After the player instantiate gameObject with this > PhotonNetwork.Instantiate("object", transform.position, Quaternion.identity);

The instantiated prefab's anchoredPosition is not be (0,0,0) for the other players. So how can i set the prefabs anchoredPosition same for the all players and the all screen resoluitons. Thanks.

Comments

  • Tobias
    Options
    Screen resolution is another topic, which should not affect world coordinates. That's a topic you have to solve. It's not network related and I don't really know how to help here.

    About the position: Sadly, we can't update the instantiate position to where the object was last seen.

    The instantiate will happen at the position you pass initially. No matter where the object is later, any joining player will instantiate the object at the initial position.
    You can disable the object at the position, wait for a first update (where the object is now) and then reposition the object before you enable and show it.