I have been all over the place and its like no one has an swer for this. but im trying to make a beatem up and im trying to make a part where if the player is leaving another player behind (if they go in opposite directions or one isnt moving) the player cant leave or move the camera i thried clamping but it just gets janky (children rig is the player and group x is the virtual cam)
public void Areana(Transform player)
childrenRig = player.GetComponentInChildren<Rigidbody>();
float childrenRigx = childrenRig.transform.position.x;
float groupX = virtualCam.transform.position.x;
childrenRig.position = new Vector3 (
Mathf.Clamp (childrenRigx, groupX -5.436225f, 0.460665f - (groupX) ),
i tried to clamp it around the players current location and the min and max is bassed off the changing x value of the virtual camera. it just gets all wrong is there a better way im bout to just give up and us box colliders as borders.