Skip to content

Commit

Permalink
CameraFollow
Browse files Browse the repository at this point in the history
  • Loading branch information
GraphicEdit committed Dec 24, 2023
1 parent a80b8e6 commit 28626ff
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DarkFlow/Assets/Prefabs/PlayerFollowCamera.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ GameObject:
- component: {fileID: 368218139850001400}
m_Layer: 0
m_Name: PlayerFollowCamera
m_TagString: Untagged
m_TagString: PlayerFollowCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand Down
96 changes: 90 additions & 6 deletions DarkFlow/Assets/Scenes/Gameplay.unity
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,55 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &107306944 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3984814823395178536, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
m_PrefabInstance: {fileID: 1889354785}
m_PrefabAsset: {fileID: 0}
--- !u!114 &107306948
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 107306944}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bd6043bde05a7fc4cba197d06915c1e3, type: 3}
m_Name:
m_EditorClassIdentifier:
Damping: {x: 0.1, y: 0.5, z: 0.3}
ShoulderOffset: {x: 0, y: 0, z: -4}
VerticalArmLength: 0.4
CameraSide: 1
CameraDistance: 2
CameraCollisionFilter:
serializedVersion: 2
m_Bits: 0
IgnoreTag:
CameraRadius: 0.2
DampingIntoCollision: 0
DampingFromCollision: 2
--- !u!1 &826060407 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8854747452121219810, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
m_PrefabInstance: {fileID: 1889354785}
m_PrefabAsset: {fileID: 0}
--- !u!114 &826060411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 826060407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 437c8746001a80e4cba174abbfefa9ed, type: 3}
m_Name:
m_EditorClassIdentifier:
m_CamFollow: {fileID: 1889354786}
--- !u!1001 &898180339
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -229,7 +278,7 @@ PrefabInstance:
- target: {fileID: 6818833442393802120, guid: 154519ab488f20d468de4e06396e2441,
type: 3}
propertyPath: field of view
value: 40
value: 39.9
objectReference: {fileID: 0}
- target: {fileID: 6818833442393802120, guid: 154519ab488f20d468de4e06396e2441,
type: 3}
Expand Down Expand Up @@ -259,12 +308,12 @@ PrefabInstance:
- target: {fileID: 6818833442393802123, guid: 154519ab488f20d468de4e06396e2441,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.66
value: 112.660286
objectReference: {fileID: 0}
- target: {fileID: 6818833442393802123, guid: 154519ab488f20d468de4e06396e2441,
type: 3}
propertyPath: m_LocalPosition.z
value: -8.07
value: -1688.0701
objectReference: {fileID: 0}
- target: {fileID: 6818833442393802123, guid: 154519ab488f20d468de4e06396e2441,
type: 3}
Expand Down Expand Up @@ -438,11 +487,26 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 368218139850001400, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_Lens.FieldOfView
value: 39.9
objectReference: {fileID: 0}
- target: {fileID: 8854747452121219810, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_Icon
value:
objectReference: {fileID: 2800000, guid: ec2f01df0bb1bfe459b5562a9e71c8d4, type: 3}
- target: {fileID: 8854747452121219810, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_Name
value: PlayerFollowCamera
objectReference: {fileID: 0}
- target: {fileID: 8854747452121219810, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_TagString
value: PlayerFollowCamera
objectReference: {fileID: 0}
- target: {fileID: 8854747452121219813, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: GlobalObjectIdHash
Expand All @@ -456,12 +520,12 @@ PrefabInstance:
- target: {fileID: 8854747452121219814, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.66
value: 112.660286
objectReference: {fileID: 0}
- target: {fileID: 8854747452121219814, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
propertyPath: m_LocalPosition.z
value: -8.07
value: -1688.0701
objectReference: {fileID: 0}
- target: {fileID: 8854747452121219814, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
Expand Down Expand Up @@ -501,8 +565,28 @@ PrefabInstance:
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 8854747452121219810, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
insertIndex: -1
addedObject: {fileID: 826060411}
- targetCorrespondingSourceObject: {fileID: 3984814823395178536, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
insertIndex: -1
addedObject: {fileID: 107306948}
m_SourcePrefab: {fileID: 100100000, guid: 773b39ed367c011418f28a8bc3b8ca31, type: 3}
--- !u!114 &1889354786 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 368218139850001400, guid: 773b39ed367c011418f28a8bc3b8ca31,
type: 3}
m_PrefabInstance: {fileID: 1889354785}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 826060407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45e653bab7fb20e499bda25e1b646fea, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &7539522792693849209
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
42 changes: 42 additions & 0 deletions DarkFlow/Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Cinemachine;
using UnityEngine;
//using UnityEngine.Assertions;

public class CameraController : MonoBehaviour
{

//private CinemachineVirtualCamera m_MainCamera;
private Transform m_CharFollow;
public CinemachineVirtualCamera m_CamFollow;

void Start()
{
AttachCamera();
}

private void AttachCamera()
{
//m_MainCamera = GameObject.FindObjectOfType<CinemachineVirtualCamera>();
//Assert.IsNotNull(m_MainCamera, "Couldn't find gameplay camera");

m_CharFollow = GameObject.FindGameObjectWithTag("Player").transform.GetChild(0).transform;

//if (m_MainCamera)
if (m_CamFollow)
{
//m_MainCamera.Follow = m_CharFollow;
m_CamFollow.Follow = m_CharFollow;
//m_MainCamera.LookAt = m_CharFollow;
m_CamFollow.LookAt = m_CharFollow;

// camera body / aim
//m_MainCamera.Follow = transform;
//m_MainCamera.LookAt = transform;
// default rotation / zoom
// m_MainCamera.m_Heading.m_Bias = 40f;
//m_MainCamera.m_YAxis.Value = 0.5f;

}
}
}

11 changes: 11 additions & 0 deletions DarkFlow/Assets/Scripts/CameraController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion DarkFlow/ProjectSettings/TagManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- PlayerFollowCamera
layers:
- Default
- TransparentFX
Expand Down

0 comments on commit 28626ff

Please sign in to comment.