Reworked camera logic
Added robot arm camera Added robot arm idle animation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Cinemachine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -7,9 +8,11 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject player;
|
||||
public Camera[] cameras;
|
||||
public GameObject networkCamera;
|
||||
public CinemachineVirtualCamera activeCamera;
|
||||
public CinemachineVirtualCamera networkCamera;
|
||||
public GameObject activeNode;
|
||||
public Node previousNode;
|
||||
public bool networkView = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -17,16 +20,14 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void SetActiveCamera(int cam)
|
||||
{
|
||||
for (int i = 0; i < cameras.Length; i++)
|
||||
{
|
||||
if (i == cam)
|
||||
{
|
||||
public void SetActiveCamera(CinemachineVirtualCamera vCam)
|
||||
{
|
||||
vCam.Priority = 20;
|
||||
activeCamera.Priority = 0;
|
||||
activeCamera = vCam;
|
||||
|
||||
}
|
||||
cameras[i].enabled = (i == cam);
|
||||
}
|
||||
if(!activeCamera == networkCamera) { networkView = false; }
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -38,9 +39,10 @@ public class GameManager : MonoBehaviour
|
||||
private void FixedUpdate()
|
||||
{
|
||||
|
||||
if (Keyboard.current.xKey.wasPressedThisFrame)
|
||||
//Leave network view with x
|
||||
if (Keyboard.current.xKey.wasPressedThisFrame && networkView)
|
||||
{
|
||||
SetActiveCamera(0);
|
||||
SetActiveCamera(networkCamera);
|
||||
activeNode.GetComponent<Node>().DisableNode();
|
||||
activeNode = null;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Node : MonoBehaviour
|
||||
if (isActive) { return; }
|
||||
Debug.Log(string.Format("{0} became active node", gameObject.name));
|
||||
UI.SetActive(true);
|
||||
gameManager.previousNode = gameManager.activeNode.GetComponent<Node>();
|
||||
gameManager.activeNode = this.gameObject;
|
||||
gameManager.networkCamera.GetComponent<NetworkCamera>().targetPosition = new Vector3(transform.position.x, gameManager.networkCamera.transform.position.y, transform.position.z);
|
||||
isActive = true;
|
||||
@@ -48,7 +49,8 @@ public class Node : MonoBehaviour
|
||||
DisableNode();
|
||||
} else
|
||||
{
|
||||
connections[(int)dir].SendMessage("InteractNode");
|
||||
connections[(int)dir].SendMessage("InteractNode", this);
|
||||
gameManager.previousNode = this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ public class Switch : MonoBehaviour
|
||||
//Debug.Log("Switch is visible and in range");
|
||||
if (Keyboard.current.eKey.wasPressedThisFrame && !gameManager.activeNode)
|
||||
{
|
||||
gameManager.SetActiveCamera(1);
|
||||
gameManager.previousNode = debugNode;
|
||||
gameManager.activeNode = debugNode.gameObject;
|
||||
gameManager.SetActiveCamera(gameManager.networkCamera);
|
||||
debugNode.SendMessage("SetActiveNode", debugNode.GetComponent<Node>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Cinemachine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -6,6 +7,10 @@ using UnityEngine.InputSystem;
|
||||
public class RobotArmController : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool isInUse = false;
|
||||
|
||||
public GameManager gameManager;
|
||||
public CinemachineVirtualCamera localCamera;
|
||||
public GameObject target;
|
||||
public float armSpeed = 1;
|
||||
public float armRotationSpeed = 10;
|
||||
@@ -16,7 +21,7 @@ public class RobotArmController : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -24,9 +29,26 @@ public class RobotArmController : MonoBehaviour
|
||||
targetMarker.transform.position = new Vector3(target.transform.position.x, transform.position.y + .5f, target.transform.position.z);
|
||||
}
|
||||
|
||||
public void InteractNode(Node pre)
|
||||
{
|
||||
gameManager.SetActiveCamera(localCamera);
|
||||
isInUse = true;
|
||||
target.GetComponent<Animator>().enabled = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (!isInUse) { return; }
|
||||
|
||||
//return to network view with x
|
||||
if (Keyboard.current.xKey.wasPressedThisFrame)
|
||||
{
|
||||
gameManager.SetActiveCamera(gameManager.networkCamera);
|
||||
target.GetComponent<Animator>().enabled = true;
|
||||
isInUse = false;
|
||||
gameManager.previousNode.SetActiveNode();
|
||||
}
|
||||
|
||||
//Hoch/Runter
|
||||
if (Keyboard.current.ctrlKey.isPressed && target.transform.position.y > transform.position.y)
|
||||
|
||||
Reference in New Issue
Block a user