I have a setup where I have a Spaceship object, with a PlayerGroup and ShipObject parented under it. The PlayerGroup is the parent of players inside that Spaceship and ShipObject has a movement script for the ship on it. The ShipObject also has the following script attached:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayersFollowShip : MonoBehaviour
{
[SerializeField] private GameObject playerGroup;
void Start()
{
var spaceshipObject = transform.root.gameObject;
playerGroup = spaceshipObject.GetComponent<Spaceship>().playerGroup.gameObject;
}
void Update()
{
playerGroup.transform.position = transform.position;
playerGroup.transform.eulerAngles = transform.eulerAngles;
}
}
When the host is in the ship and parented under the player group, when the ship is moved with the movement script, the host’s player object stays in place correctly inside the spaceship, but when I do the same with a client it always physically lags behind the ship. Any ideas on how to fix this and make sure the client player object correctly stays inside the spaceship and doesn’t lag behind it?