Using Advanced Tutorial, Clients Have Equal Control Over All Entities in The Lobby

Options

I've been following the "Advanced Tutorial" for Bolt and just ran into an issue that I cannot seem to get around. I've managed to establish a connection which creates two drivable cars that use Unity Physics and move using wheel colliders. When two connections enter a lobby, everything works wonderfully. Two cars are instantiated, and the players can drive the cars. The problem is that each connection's input actually controls both cars at the same time rather than just their own vehicle.

I initially thought this had to be an issue with how control of the entities were assigned, so I checked the tutorial and the code (as well as mine) uses: entity.AssignControl(connection);

I'm stumped. I physically have two vehicles with two connections, but I can't seem to give each connection individual control. I've tried double checking the tutorial, but I can't find any noticeable differences between what was taught and what I have. I was hoping to get some insight to what might be causing this particular issue.

Summary: Each Photon Bolt Connection has the same control as each other over all vehicle entities in the lobby. Instead of this, I want each connection to have control of an individual vehicle, not all vehicles.

Here is what I believe to be the relevant script:

using UnityEngine;

public class TutorialPlayerObject
{
public BoltEntity character;
public BoltConnection connection;

public bool IsServer
{
get { return connection == null; }
}

public bool IsClient
{
get { return connection != null; }
}

public void Spawn()
{
if (!character)
{
character = BoltNetwork.Instantiate(BoltPrefabs.SedanCar, RandomPosition(), Quaternion.identity);

if (IsServer)
{
character.TakeControl();
}
else
{
character.AssignControl(connection);
}
}

// teleport entity to a random spawn position
character.transform.position = RandomPosition();
}

Vector3 RandomPosition()
{
float x = Random.Range(-16f, +16f);
float z = Random.Range(-16f, +16f);
return new Vector3(x, 5f, z);
}
}


Thank you to anyone who answers :)

Comments