CameraController and ReactiveCamera + Prefab for CameraWithTrigger and

Frank added
This commit is contained in:
GungHolo 2023-06-06 22:10:54 +02:00
parent 8d381baffd
commit 645c21bb95
10 changed files with 3798 additions and 0 deletions

View File

@ -0,0 +1,212 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2815367761964512228
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2815367761964512235}
- component: {fileID: 2815367761964512234}
- component: {fileID: 2815367761964512229}
- component: {fileID: 2815367761964512232}
m_Layer: 0
m_Name: cam1
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2815367761964512235
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367761964512228}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -8.5665, y: 3.7686763, z: -11.400221}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2815367762385643464}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &2815367761964512234
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367761964512228}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: -0.03
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!81 &2815367761964512229
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367761964512228}
m_Enabled: 0
--- !u!114 &2815367761964512232
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367761964512228}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!1 &2815367762385643467
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2815367762385643464}
- component: {fileID: 2815367762385643465}
- component: {fileID: 2815367762385643470}
- component: {fileID: 2815367762385643471}
m_Layer: 0
m_Name: CameraWithTrigger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2815367762385643464
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367762385643467}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 7.7465, y: -4.578676, z: 2.9067402}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2815367761964512235}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!68 &2815367762385643465
EdgeCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367762385643467}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.56, y: 0}
m_EdgeRadius: 0
m_Points:
- {x: 0, y: 3.19}
- {x: 0, y: -0.84}
m_AdjacentStartPoint: {x: 0, y: 0}
m_AdjacentEndPoint: {x: 0, y: 0}
m_UseAdjacentStartPoint: 0
m_UseAdjacentEndPoint: 0
--- !u!50 &2815367762385643470
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367762385643467}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!114 &2815367762385643471
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2815367762385643467}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1d469014f8afb2d4ea0308a0a86bef05, type: 3}
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 0}
col: {fileID: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 560b69619ffa27c42ac31fb4d91b1c81
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

209
Assets/AssetsFORELLE/Prefabs/Frank.prefab generated Normal file
View File

@ -0,0 +1,209 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2410396854066836738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2410396854066836746}
- component: {fileID: 2410396854066836741}
- component: {fileID: 2410396854066836740}
- component: {fileID: 2410396854066836743}
- component: {fileID: 2410396854066836742}
- component: {fileID: 2410396854066836737}
- component: {fileID: 2410396854066836736}
- component: {fileID: 2410396854066836739}
- component: {fileID: 2410396854066836747}
m_Layer: 0
m_Name: Frank
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2410396854066836746
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -36.74, y: 2.17, z: -0.022044204}
m_LocalScale: {x: 0.42547998, y: 0.3653795, z: 0.42548}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2410396854066836741
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: bc1e36585ebd79d4db8ca18c1637587d, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 3.41, y: 3.203125}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &2410396854066836740
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 57eab097b9fc58c4c88a5c9ba60e9c64, type: 3}
m_Name:
m_EditorClassIdentifier:
maxSpeed: 3.4
jumpHeight: 8
gravityScale: 1.5
mainCamera: {fileID: 0}
grounded: 0
--- !u!70 &2410396854066836743
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 9a162dcdc92b4194ba53630f8785bed1, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.11321017, y: -0.15380491}
m_Size: {x: 1.9948646, y: 2.498772}
m_Direction: 0
--- !u!50 &2410396854066836742
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 1
m_Mass: 0.6203283
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 6200000, guid: 9a162dcdc92b4194ba53630f8785bed1, type: 2}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!95 &2410396854066836737
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 44043e1d2a4d940438b0fdfee3f92bb0, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!70 &2410396854066836736
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 9a162dcdc92b4194ba53630f8785bed1, type: 2}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.15, y: 0}
m_Size: {x: 1.64, y: 2.91}
m_Direction: 1
--- !u!114 &2410396854066836739
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4760965f3d035f84db6a6741d746428c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &2410396854066836747
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bef524aa2ad305d4faf6b90a610e5be4, type: 3}
m_Name:
m_EditorClassIdentifier:
inFirstDim: 1

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 22badd0525f460b4d988841429f6a07e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
Static Class which takes role of Controller for all the Cameras/Triggers
IMPORTANT!!!
The Priority of the FIRST Camera that should be shown has to be set manually to 100
The Priorities of the OTHER cameras can be anything else then 100
IMPORTANT!!!
*/
public static class CameraController
{
public static Camera currentCam;
static List<Camera> cameras = new List<Camera>();
public static void Register(Camera cam)
{
cameras.Add(cam);
}
public static void ActivateCamera(Camera cam)
{
cam.depth = 100;
currentCam = cam;
foreach (Camera c in cameras)
{
if(c != currentCam) c.depth = 0;
}
}
public static Camera CurrentCamera()
{
return currentCam;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c367d6ffd5aab154a8e755b921c7176c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
Sends the necessary Requests to the CameraController saying "Hi i want to be rendered"
The CameraController then obliges like the nice Guy he is :)
*/
public class ReactiveCamera : MonoBehaviour
{
[SerializeField] private Camera cam;
[SerializeField] private EdgeCollider2D col;
Rigidbody2D rb;
void Start()
{
col = GetComponent<EdgeCollider2D>();
rb = GetComponent<Rigidbody2D>();
cam = GetComponentInChildren<Camera>();
rb.isKinematic = true;
CameraController.Register(cam);
}
// Update is called once per frame
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Player"))
{
if(CameraController.CurrentCamera() != cam) CameraController.ActivateCamera(cam);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d469014f8afb2d4ea0308a0a86bef05
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3261
Assets/Scenes/LevelTest_Luca.unity generated Normal file

File diff suppressed because it is too large Load Diff

7
Assets/Scenes/LevelTest_Luca.unity.meta generated Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3fcfa7fb4184bd44da8bbc08562ddfdc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: