game(scripts): add CameraFollower and TriggerFunctionRemapper
This commit is contained in:
parent
5c3b689de1
commit
6ed56e2e58
4 changed files with 69 additions and 0 deletions
24
Game/Assets/Scripts/CameraFollower.cs
Normal file
24
Game/Assets/Scripts/CameraFollower.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Author: Mark
|
||||||
|
* Date: 16/2/25
|
||||||
|
* Description: follows the XR Camera's position
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class XRColliderFollow : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Transform xrCamera;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (xrCamera != null) return;
|
||||||
|
throw new Exception("Please assign the XR Camera to the XRColliderFollow script!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
transform.position = xrCamera.position;
|
||||||
|
}
|
||||||
|
}
|
11
Game/Assets/Scripts/CameraFollower.cs.meta
Normal file
11
Game/Assets/Scripts/CameraFollower.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 27b115b1b7297054cabb4ec1e403b751
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
23
Game/Assets/Scripts/TriggerFunctionRemapper.cs
Normal file
23
Game/Assets/Scripts/TriggerFunctionRemapper.cs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Author: Mark
|
||||||
|
* Date: 16/2/25
|
||||||
|
* Description: allows changing what code is executed when a trigger is entered
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TriggerFunctionRemapper : MonoBehaviour
|
||||||
|
{
|
||||||
|
private Action<Collider> _onTriggerEnter;
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
_onTriggerEnter?.Invoke(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remap(Action<Collider> func)
|
||||||
|
{
|
||||||
|
_onTriggerEnter = func;
|
||||||
|
}
|
||||||
|
}
|
11
Game/Assets/Scripts/TriggerFunctionRemapper.cs.meta
Normal file
11
Game/Assets/Scripts/TriggerFunctionRemapper.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 396d8c6bf380c7241bc652343cbf11f6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Add table
Reference in a new issue