Spectating
This commit is contained in:
@@ -1758,7 +1758,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 153506}
|
m_GameObject: {fileID: 153506}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -944.5319, y: 0, z: 100.35948}
|
m_LocalPosition: {x: -1356.3917, y: 0, z: 100.35948}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 58f7e79a87c79824597746e8c1bfe400
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f58d25b9e504a4f41ab4a71cf87c1845
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1 +1 @@
|
|||||||
{"count":1,"self":34.8998752,"total":35.1358813,"children":{"InitializeActuators":{"count":4,"self":0.0010003,"total":0.0010003,"children":null},"InitializeSensors":{"count":4,"self":0.0021273,"total":0.0021273,"children":null},"AgentSendState":{"count":1451,"self":0.13457819999999998,"total":0.21487389999999998,"children":{"CollectObservations":{"count":1153,"self":0.0682126,"total":0.0682126,"children":null},"WriteActionMask":{"count":328,"self":0.0009983,"total":0.0009983,"children":null},"RequestDecision":{"count":328,"self":0.0085863,"total":0.011084799999999999,"children":{"RayPerceptionSensor.Perceive":{"count":656,"self":0.0024985,"total":0.0024985,"children":null}}}}},"DecideAction":{"count":626,"self":0.0138103,"total":0.0138103,"children":null},"AgentAct":{"count":626,"self":0.0031948,"total":0.0031948,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714039602","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\hassa\\OneDrive\\Skrivebord\\alt pro\\Unity stuff\\Unity ting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-hassa -hubSessionId 45b5d559-24dc-4b99-a8b6-a125447684df -accessToken bXHJaHm6Ggta2huR1hMWbJtprK9AdD_DuLyfh8whvdM005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Racetrack mini","end_time_seconds":"1714039637"}}
|
{"count":1,"self":11.6306104,"total":11.723526699999999,"children":{"InitializeActuators":{"count":8,"self":0.0069854,"total":0.0069854,"children":null},"InitializeSensors":{"count":8,"self":0.0059865,"total":0.0059865,"children":null},"AgentSendState":{"count":324,"self":0.0320017,"total":0.042003,"children":{"CollectObservations":{"count":520,"self":0.0049726,"total":0.0049726,"children":null},"WriteActionMask":{"count":520,"self":0,"total":0,"children":null},"RequestDecision":{"count":520,"self":0.0030489,"total":0.0050287,"children":{"RayPerceptionSensor.Perceive":{"count":1040,"self":0.0019798,"total":0.0019798,"children":null}}}}},"DecideAction":{"count":324,"self":0.0040523999999999994,"total":0.0040523999999999994,"children":null},"AgentAct":{"count":324,"self":0.0328913,"total":0.0328913,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714049733","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\Magnus\\Desktop\\Ny unityting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Magnus -hubSessionId 8c17471b-7795-4082-905c-75744d6a077b -accessToken FV38BX0LdlmK-m4amNy3jH1hDBMyOs3Ki2__yJqeaFY005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Racetrack mini","end_time_seconds":"1714049745"}}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ using Unity.VisualScripting;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
//script from FREAKINGREX, but minor changes to integrate it proberly
|
//script from FREAKINGREX, but changes to integrate it proberly/ work how we want it to work
|
||||||
//https://assetstore.unity.com/packages/templates/systems/arcade-car-controller-lite-version-145489
|
//https://assetstore.unity.com/packages/templates/systems/arcade-car-controller-lite-version-145489
|
||||||
|
|
||||||
public class CameraControl :MonoBehaviour
|
public class CameraControl :MonoBehaviour
|
||||||
@@ -68,6 +68,7 @@ public class CameraControl :MonoBehaviour
|
|||||||
|
|
||||||
transform.position = Vector3.LerpUnclamped (transform.position, TargetPoint, Time.deltaTime * ActivePreset.SetPositionSpeed);
|
transform.position = Vector3.LerpUnclamped (transform.position, TargetPoint, Time.deltaTime * ActivePreset.SetPositionSpeed);
|
||||||
|
|
||||||
|
|
||||||
if (Input.GetKeyDown (SetCameraKey))
|
if (Input.GetKeyDown (SetCameraKey))
|
||||||
{
|
{
|
||||||
SetNextCamera ();
|
SetNextCamera ();
|
||||||
@@ -111,6 +112,7 @@ public class CameraControl :MonoBehaviour
|
|||||||
|
|
||||||
public void UpdateActiveCamera ()
|
public void UpdateActiveCamera ()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ActivePreset != null)
|
if (ActivePreset != null)
|
||||||
{
|
{
|
||||||
ActivePreset.CameraHolder.SetActive(false);
|
ActivePreset.CameraHolder.SetActive(false);
|
||||||
|
|||||||
@@ -13,49 +13,42 @@ public class GameController :MonoBehaviour
|
|||||||
[SerializeField] UnityEngine.UI.Button NextCarButton;
|
[SerializeField] UnityEngine.UI.Button NextCarButton;
|
||||||
public static GameController Instance;
|
public static GameController Instance;
|
||||||
public GameObject PlayerCar;
|
public GameObject PlayerCar;
|
||||||
|
public GameObject cam;
|
||||||
public static bool RaceIsStarted { get { return true; } }
|
public static bool RaceIsStarted { get { return true; } }
|
||||||
public static bool RaceIsEnded { get { return false; } }
|
public static bool RaceIsEnded { get { return false; } }
|
||||||
|
|
||||||
PlayerController m_PlayerCar;
|
//PlayerController m_PlayerCar;
|
||||||
List<PlayerController> Cars = new List<PlayerController>();
|
//List<PlayerController> Cars = new List<PlayerController>();
|
||||||
|
public List<GameObject> cars;
|
||||||
int CurrentCarIndex = 0;
|
int CurrentCarIndex = 0;
|
||||||
|
|
||||||
protected virtual void Awake ()
|
protected virtual void Awake ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
//Find all cars in current game.
|
// foreach (var car in cars)
|
||||||
Cars.AddRange (GameObject.FindObjectsOfType<PlayerController> ());
|
// {
|
||||||
Cars = Cars.OrderBy (c => c.name).ToList();
|
// var userControl = car.GetComponent<PlayerController>();
|
||||||
|
// var audioListener = car.GetComponent<AudioListener>();
|
||||||
|
|
||||||
foreach (var car in Cars)
|
// if (userControl == null)
|
||||||
{
|
// {
|
||||||
var userControl = car.GetComponent<PlayerController>();
|
// userControl = car.gameObject.AddComponent<PlayerController> ();
|
||||||
var audioListener = car.GetComponent<AudioListener>();
|
// }
|
||||||
|
|
||||||
if (userControl == null)
|
// if (audioListener == null)
|
||||||
{
|
// {
|
||||||
userControl = car.gameObject.AddComponent<PlayerController> ();
|
// audioListener = car.gameObject.AddComponent<AudioListener> ();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (audioListener == null)
|
// userControl.enabled = false;
|
||||||
{
|
// audioListener.enabled = false;
|
||||||
audioListener = car.gameObject.AddComponent<AudioListener> ();
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
userControl.enabled = false;
|
|
||||||
audioListener.enabled = false;
|
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
|
||||||
}
|
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
|
||||||
|
|
||||||
m_PlayerCar = Cars[0];
|
|
||||||
m_PlayerCar.GetComponent<PlayerController> ().enabled = true;
|
|
||||||
m_PlayerCar.GetComponent<AudioListener> ().enabled = true;
|
|
||||||
|
|
||||||
if (NextCarButton)
|
|
||||||
{
|
|
||||||
NextCarButton.onClick.AddListener (NextCar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update ()
|
void Update ()
|
||||||
@@ -69,14 +62,20 @@ public class GameController :MonoBehaviour
|
|||||||
|
|
||||||
private void NextCar ()
|
private void NextCar ()
|
||||||
{
|
{
|
||||||
m_PlayerCar.GetComponent<PlayerController> ().enabled = false;
|
// cars[CurrentCarIndex].GetComponent<PlayerController> ().enabled = false;
|
||||||
m_PlayerCar.GetComponent<AudioListener> ().enabled = false;
|
// cars[CurrentCarIndex].GetComponent<AudioListener> ().enabled = false;
|
||||||
|
|
||||||
CurrentCarIndex = LoopClamp (CurrentCarIndex + 1, 0, Cars.Count);
|
CurrentCarIndex = LoopClamp (CurrentCarIndex + 1, 0, cars.Count);
|
||||||
|
|
||||||
m_PlayerCar = Cars[CurrentCarIndex];
|
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
|
||||||
m_PlayerCar.GetComponent<PlayerController> ().enabled = true;
|
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
|
||||||
m_PlayerCar.GetComponent<AudioListener> ().enabled = true;
|
|
||||||
|
PlayerCar = cars[CurrentCarIndex];
|
||||||
|
|
||||||
|
cam.GetComponent<CameraControl>().getCar(PlayerCar);
|
||||||
|
|
||||||
|
|
||||||
|
print(PlayerCar.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int LoopClamp (int value, int minValue, int maxValue)
|
public static int LoopClamp (int value, int minValue, int maxValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user