Add an offset to the position of an object in front of it

Essentially I have a game with 1-6 players on a board. To stop all players spawning in the exact same spawn point I’m trying to implement a system where by a cube will rotate each time a player is spawned by the number of 360/number of players and then will offset the players position slightly. So they will all be equally spaced from the spawn cube and the same angle apart. But I am unsure how to add to the transform.position in the cubes “forward direction”.

Transform playerSpawnPoint = this.transform;
float angle = 360 / NumberofPlayers;

    for (int i = 0; i < NumberofPlayers; i++)
    {
        Debug.Log("spawning player " + i);
        this.transform.rotation = Quaternion.AngleAxis(angle*i, transform.up);
        playerSpawnPoint.position = playerSpawnPoint.position + Vector3.forward ;
        Instantiate(playerm, playerSpawnPoint);

    }

To rotate a Vector around another Vector you have to multiply it with a Quaternion like this:

Vector3 direction = Quaternion.Euler(90, 0, 0) * (startPoint - pivot);
Vector3 spawnPoint = direction + pivot;

The startPoint is the first possible spawn position. The pivot is the center of the circle and the 90 is one example of a possible angle. I think you can solve the problem now :wink: