1 (edited by tamim.ali.zoabi 2019-10-13 18:51:22)

Topic: ChangeLocation

Hi
I am using Pun2 there is a master that can see every player position on his screen .
when some one moved his device location i need to notice the master about his new location .
so i add an event OnLocationChanged for every player and in that event function i added a RPC function that send the new location to the master .
but new locations doesn't shown.or Updated .
do i need to use (OnlineMaps.instance.Redraw();) "i used it
what i supposed to do ?

Re: ChangeLocation

Hello.

Based on your description, it's hard to say what's wrong.
Please show the full script.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: ChangeLocation

Hi
i need to know if that enough to ReDraw the new marker position ? it doesnt redraw the marker with the new position .. if this device is in a moiving car it should show the marker moving on the master screen after sending this RPC Function ?!!

private void OnLocationChanged(Vector2 position)
    {
        MPV = Add_Room.go_to_Player_room.GetComponent<PhotonView>();
        // Change the position of the marker.
        playerMarker.position = position;
        First_Connection.GClass.The_Marker[0].marker.position = position;
        First_Connection.GClass.The_Marker[0].Latitude = position.y;
        First_Connection.GClass.The_Marker[0].Longtude = position.x;
        First_Connection.GClass.The_Marker[0].position = position;
        //First_Connection.GClass.The_Marker[0].marker.position = position;
        OnlineMaps.instance.Redraw();
        if (First_Connection.MC.PI.Player_Is_Master == false)
            MPV.RPC("SendMyLoacationToMaster", RpcTarget.MasterClient, position, Load_Rooms.Player_Name);

and the RPC function is :
[PunRPC]
    private void SendMyLoacationToMaster(Vector2 Position,string name)
    {
        int found = 0;
        if (First_Connection.MC.PI.Player_Is_Master == false)
        {
            for (int i = 0; i < First_Connection.GClass.The_Driver.Count; i++)
            {
                if (First_Connection.GClass.The_Driver[i ].Driver_Name == name)
                {
                    First_Connection.GClass.The_Driver[i ].position = Position;
                    First_Connection.GClass.The_Driver[i ].marker.position = Position;
                    Debug.Log("Send My Locateion To Master : " + First_Connection.GClass.The_Driver[i ].Driver_Name);
                    found = 1;
                    //return;
                }
            }
            if (found == 0)
            {
                Driver driver = new Driver();
                Texture2D txtr;
                txtr = Resources.Load("c620c6b7a2b0e22a05e179ed8e7ab6b0_icon") as Texture2D;
                // txtr = Resources.Load("Taxi") as Texture2D;
                //OnlineMapsLocationService locationService = OnlineMapsLocationService.instance;
                // Create a new marker.
                driver.marker = OnlineMapsMarkerManager.CreateItem(Position, txtr, name);
                //playerMarker.align = OnlineMapsAlign.Center;
                driver.latitude = Position.y;
                driver.longtude = Position.x;
                driver.position = Position;
                driver.Driver_Found_And_Updated = false;
                driver.Driver_Not_Found_Counter = 0;
                //driver.marker = playerMarker;
                driver.Time_Enter_Room = System.DateTime.Now;
                driver.Time_He_Push_Free = System.DateTime.Now;
                Debug.Log("Marker Created Successfully......");
                driver.Driver_Name = name;
                First_Connection.GClass.The_Driver.Add(driver);
            }
            OnlineMaps.instance.Redraw();
        }
    }

Re: ChangeLocation

First_Connection.MC.PI.Player_Is_Master
This line checks that the current player is a master, right?
In this case, why does SendMyLoacationToMaster check that the current player is not a master?
Most likely it should be checked that the current player is a master.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: ChangeLocation

Ok ..
The code is little more complex ... Forgote the code .. let me ask you with another more simple way .
I have created a Marker and it shown on my screen .
My Quistion : for changing the position of the marker .I need just to type : marker.positiin=new vector2(32.0000,35.000);
my Quistion is this line enough to change the marker position ?

Re: ChangeLocation

No, you need to invoke the map redraw (OnlineMaps.instance.Redraw).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: ChangeLocation

Thanks a lot I'll try it