Hey guys, I’m working on a multiplayer game, I have everything working.
But the Canvas is weird to work with…
I have each player spawn with a Canvas, etc.
Well, When I spawn the player, he has to be at rotation of 0, but what if I want to spawn the player at a different angle. I mean nobody always wants to spawn in the same direction no matter what team you are.
Is there any way to spawn player and have the canvas rotate to the direction the play spawns?
If it’s a world-space canvas childed to the player GameObject, it should automatically match rotation. Otherwise add a script like this:
using UnityEngine;
public class MatchRotation : MonoBehaviour {
public Transform player;
public Transform canvas;
void OnStart() {
canvas.rotation = player.rotation;
}
}
You’ll need to assign player and canvas. Or put it on one of the GameObjects and use that GameObject’s transform in place of player or canvas.