Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Position of the LocalPlayer is not working

Discussion in 'Multiplayer' started by UDN_60115ee5-2147-4fcc-8ff0-dd54695f410f, Mar 25, 2017.

  1. UDN_60115ee5-2147-4fcc-8ff0-dd54695f410f

    UDN_60115ee5-2147-4fcc-8ff0-dd54695f410f

    Joined:
    Jan 29, 2017
    Posts:
    8
    I have a 2D player, and it has to be in the Canvas.
    Because my NetworkHUD spawns it outside the Canvas, I make my player get inside the canvas and set new position and resize with the following function:

    Code (CSharp):
    1. public override void OnStartLocalPlayer()
    2.     {
    3.         canvas = GameObject.FindWithTag("Canvas");
    4.         transform.SetParent(canvas.transform);
    5.         Vector3 position = new Vector3(-9.9f, -20.8f, 0);
    6.         transform.position = position;
    7.         Vector3 scale = new Vector3(1, 1, 1);
    8.         transform.localScale = scale;
    9. }
    The problem is that it resizes well, but it doesn't change the position for some reason, and because that, inside the Canvas, it doesn't show well.
    Any solution?
     
  2. UDN_60115ee5-2147-4fcc-8ff0-dd54695f410f

    UDN_60115ee5-2147-4fcc-8ff0-dd54695f410f

    Joined:
    Jan 29, 2017
    Posts:
    8
    Anyone?