Instantiate Object at Cursor Position

Hey developers.
I am pretty new on developing a multiplayer game, but I wanted to give it a try.
I try to create a multiplayer game (based on Photon), where a mechanic is that players can spawn walls at the position, their cursor is pointing. For some reason it doesn't work completely. The host's instantiated objects are at the correct cursor position, while the client's instantiated objects are not at the right spot of the world space. Here's a picture to visualize my problem better:


You can see in the console that the positions of the client are not in the actual game area, as well of course the walls as well.

Here's the code

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

public class WallPlacing : MonoBehaviourPunCallbacks
    public GameObject wallGameObject;
    bool isInstantiated = false;

    PhotonView view;
    void Start()
    {   //get the photon view component
        view = GetComponent<PhotonView>();

    // Update is called once per frame
    void Update()
        if (view.IsMine)
            if (Input.GetKeyDown(KeyCode.LeftControl))
                view.RPC(nameof(PlaceWall), RpcTarget.All);

    //place a wall at cursos pos
    void PlaceWall()

        Vector2 cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        PhotonNetwork.InstantiateRoomObject(, new Vector3(cursorPos.x, cursorPos.y, 1), Quaternion.identity);
        //GameObject wall = Instantiate(wallGameObject, new Vector3(cursorPos.x, cursorPos.y, 1), Quaternion.identity);


Does someone know how to fix this Problem?

1 Like

bro du u get any answer please let me know i have same problem