- Home /
Question by
Plutonia · Aug 14, 2016 at 07:30 AM ·
scripting problemuiunity5canvas
How to attach a (that world type) canvas to a moving player?
Hi! I tried this script, but it doesn;t work:
public Vector3 position;
public GameObject ship;
public Camera mainCamera;
private Vector3 shipPosition;
public Canvas canvas;
// Use this for initialization
void Start()
{
shipPosition = ship.transform.position;
}
// Update is called once per frame
void Update()
{
InvokeRepeating("SetCanvasPosition", 0f, 0f);
}
void SetCanvasPosition()
{
canvas.transform.Translate(shipPosition);
}
Comment
If it is about displaying some little information on that canvas how about you make that canvas a child of ship and when ship moves the canvas moves as well.