Skip to content

Commit

Permalink
Added secondary camera to Stretch Robot, and used third-party camera …
Browse files Browse the repository at this point in the history
…setup for rendering it
  • Loading branch information
elimvb committed Dec 2, 2021
1 parent 128a072 commit b3a89e4
Show file tree
Hide file tree
Showing 3 changed files with 319 additions and 83 deletions.
2 changes: 1 addition & 1 deletion unity/Assets/Scripts/BaseFPSAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public BaseFPSAgentController(BaseAgentComponent baseAgentComponent, AgentManage
this.m_WalkSpeed = 2;
this.m_RunSpeed = 10;
this.m_GravityMultiplier = 2;
this.m_Camera = this.gameObject.GetComponentInChildren<Camera>();
this.m_Camera = this.transform.Find("FirstPersonCharacter").GetComponent<Camera>();
this.m_CharacterController = GetComponent<CharacterController>();
collidedObjects = new string[0];
collisionsInAction = new List<string>();
Expand Down
8 changes: 8 additions & 0 deletions unity/Assets/Scripts/StretchAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public override void InitializeBody() {
standingLocalCameraPosition = m_Camera.transform.localPosition;
crouchingLocalCameraPosition = m_Camera.transform.localPosition;

// set secondary arm-camera
Camera fp_camera_2 = m_CharacterController.transform.Find("FirstPersonCharacter").Find("SecondaryCamera").GetComponent<Camera>();
fp_camera_2.gameObject.SetActive(true);
fp_camera_2.transform.localPosition = new Vector3(-0.01760002f, 0.1291f, -0.1512001f);
fp_camera_2.transform.localEulerAngles = new Vector3(45f, 90f, 0f);
fp_camera_2.fieldOfView = 60f;
this.agentManager.thirdPartyCameras.Add(fp_camera_2);

// limit camera from looking too far down
this.maxDownwardLookAngle = 90f;
this.maxUpwardLookAngle = 25f;
Expand Down
Loading

0 comments on commit b3a89e4

Please sign in to comment.