ciruclar loop added for bodies & camera updates
This commit is contained in:
@@ -13,8 +13,10 @@ public class BodyManager : MonoBehaviour
|
||||
public int m_DefaultPoolCapacity;
|
||||
public int m_MaxPoolCapacity;
|
||||
public Transform m_Parent;
|
||||
public Transform m_SpawnParent;
|
||||
private Vector3 m_PelvisPosition;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance != null)
|
||||
@@ -35,8 +37,8 @@ public class BodyManager : MonoBehaviour
|
||||
|
||||
private Body CreateBody()
|
||||
{
|
||||
Vector3 spawnPos = new Vector3(this.transform.position.x + Random.Range(-0.5f, 0.5f), this.transform.position.y, this.transform.position.z + Random.Range(-0.5f, .5f));
|
||||
Body body = Instantiate(m_Rigidbody, spawnPos, new Quaternion(Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180)), m_Parent);
|
||||
Vector3 spawnPos = new Vector3(this.transform.position.x + Random.Range(-0.2f, 0.2f), this.transform.position.y, this.transform.position.z + Random.Range(-0.2f, .2f));
|
||||
Body body = Instantiate(m_Rigidbody, m_SpawnParent.position, new Quaternion(Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180)), m_Parent);
|
||||
body.m_Pelvis.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(1, 1, 1));
|
||||
m_PelvisPosition = body.m_Pelvis.position;
|
||||
body.SetPool(m_Pool);
|
||||
@@ -45,7 +47,7 @@ public class BodyManager : MonoBehaviour
|
||||
|
||||
private void OnTakeBodyFromPool(Body body)
|
||||
{
|
||||
body.m_Pelvis.transform.position = m_PelvisPosition;
|
||||
body.m_Pelvis.transform.position = m_SpawnParent.position;
|
||||
body.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ public class BodyManager : MonoBehaviour
|
||||
|
||||
IEnumerator Spawn()
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(Random.Range(3f, 7f));
|
||||
yield return new WaitForSecondsRealtime(Random.Range(1f, 2.5f));
|
||||
m_Pool.Get();
|
||||
StartCoroutine(Spawn());
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class CameraManager : MonoBehaviour
|
||||
m_Camera.cullingMask = m_Bodies;
|
||||
break;
|
||||
case "vc_Environment":
|
||||
m_Camera.cullingMask = m_Bodies;
|
||||
m_Camera.cullingMask = m_Environment;
|
||||
break;
|
||||
default:
|
||||
case "vc_Default":
|
||||
@@ -153,7 +153,8 @@ public class CameraManager : MonoBehaviour
|
||||
CinemachineBrain cmBrain = m_Brain.GetComponent<CinemachineBrain>();
|
||||
float blendtime = (float)Random.Range(m_CameraBlendMin, m_CameraBlendMax);
|
||||
|
||||
if (AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Body", "vc_Agent"))
|
||||
if (AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Body", "vc_Agent") || AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Environment", "vc_Agent") || AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Environment", "vc_Body")
|
||||
|| AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Environment", "vc_Environment") || AreDifferentPairs(pastCamera.tag, m_ActiveCamera.tag, "vc_Body", "vc_Body"))
|
||||
blendtime = 0;
|
||||
|
||||
cmBrain.m_DefaultBlend.m_Time = blendtime;
|
||||
@@ -185,7 +186,8 @@ public class CameraManager : MonoBehaviour
|
||||
{
|
||||
foreach(Transform child in parentObject.transform)
|
||||
{
|
||||
m_CameraObjects.Add(child.gameObject);
|
||||
if(child.gameObject.activeSelf)
|
||||
m_CameraObjects.Add(child.gameObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -201,6 +203,8 @@ public class CameraManager : MonoBehaviour
|
||||
{
|
||||
Debug.LogError("CM Brain <GameObject> could not be found.");
|
||||
}
|
||||
|
||||
Debug.Log(m_CameraObjects.Count);
|
||||
|
||||
}
|
||||
|
||||
|
||||
12
Assets/8_Scripts/2_General/RotationOffset.cs
Normal file
12
Assets/8_Scripts/2_General/RotationOffset.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RotationOffset : MonoBehaviour
|
||||
{
|
||||
private float m_Speed = 2.5f;
|
||||
private void FixedUpdate()
|
||||
{
|
||||
transform.RotateAround(transform.parent.transform.position, Vector3.up, m_Speed * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
11
Assets/8_Scripts/2_General/RotationOffset.cs.meta
generated
Normal file
11
Assets/8_Scripts/2_General/RotationOffset.cs.meta
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdec66b4af82b494f830bb5ac54844ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user