portals and dash. Also a bit of terrain building and level design
This commit is contained in:
117
Assets/Project Files/Scripts/JonasB/ActionGestureInteraction.cs
Normal file
117
Assets/Project Files/Scripts/JonasB/ActionGestureInteraction.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ActionGestureInteraction : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> objects;
|
||||
|
||||
private Transform rightHandTransform;
|
||||
private GameObject player;
|
||||
|
||||
/**public int blinkUses;
|
||||
public float blinkCooldown, blinkDistance, blinkSpeed, blinkDestinationMultiplier;
|
||||
public LayerMask blinkLayerMask;**/
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
player = GameObject.Find("XR Origin");
|
||||
rightHandTransform = player.transform.Find("Camera Offset").Find("RightHand Controller").transform;
|
||||
}
|
||||
|
||||
public void PerformAction(string action)
|
||||
{
|
||||
//Debug.Log(action);
|
||||
//if (action == "Blink")
|
||||
//{
|
||||
//BlinkCast(); [DEPRECATED]
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
foreach (var item in objects)
|
||||
{
|
||||
if (item.name == action)
|
||||
{
|
||||
Instantiate(item, rightHandTransform.position, Quaternion.identity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
/**
|
||||
int maxUses;
|
||||
float cooldownTimer;
|
||||
bool blinking = false;
|
||||
Vector3 destination;
|
||||
**/
|
||||
private void Update()
|
||||
{
|
||||
// Blink cooldown action;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** [DEPRECATED]
|
||||
void BlinkCast()
|
||||
{
|
||||
Transform cameraTransform = Camera.main.transform;
|
||||
Transform playerTransform = player.transform;
|
||||
ParticleSystem blinkTrail = player.transform.Find("BlinkTrail").GetComponent<ParticleSystem>();
|
||||
maxUses = blinkUses;
|
||||
cooldownTimer = blinkCooldown;
|
||||
|
||||
Blink();
|
||||
if (blinkUses < maxUses)
|
||||
{
|
||||
if (cooldownTimer > 0)
|
||||
{
|
||||
cooldownTimer -= Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
blinkUses += 1;
|
||||
cooldownTimer = blinkCooldown;
|
||||
}
|
||||
|
||||
if (blinking)
|
||||
{
|
||||
|
||||
var dist = Vector3.Distance(playerTransform.position, destination);
|
||||
if (dist > 0.5f)
|
||||
{
|
||||
Debug.Log(Time.deltaTime * blinkSpeed);
|
||||
playerTransform.position = Vector3.MoveTowards(playerTransform.position, destination, blinkDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
blinking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Blink()
|
||||
{
|
||||
if (blinkUses > 0)
|
||||
{
|
||||
blinkUses -= 1;
|
||||
blinkTrail.Play();
|
||||
//RaycastHit hit;
|
||||
if (Physics.Raycast(playerTransform.position, playerTransform.forward, out hit, blinkDistance, blinkLayerMask))
|
||||
{
|
||||
Debug.Log(hit.transform.name);
|
||||
destination = hit.point * blinkDestinationMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = (cameraTransform.position + cameraTransform.forward.normalized * blinkDistance) * blinkDestinationMultiplier;
|
||||
//}
|
||||
|
||||
|
||||
destination.y += Camera.main.transform.position.y;
|
||||
blinking = true;
|
||||
}
|
||||
}
|
||||
}**/
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 191e423e742cc6d499e2feab007d8861
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Project Files/Scripts/JonasB/BasicPortal.cs
Normal file
51
Assets/Project Files/Scripts/JonasB/BasicPortal.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BasicPortal : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private BasicPortal linkedPortal;
|
||||
public float _portalCooldown = 5.0f;
|
||||
private bool _isPortalEnabled;
|
||||
private float _lastUsed;
|
||||
private bool _justUsed;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_isPortalEnabled = true;
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.tag == "Player" && _isPortalEnabled)
|
||||
{
|
||||
Debug.Log("Player stepped into portal");
|
||||
_justUsed = true;
|
||||
linkedPortal._isPortalEnabled = false;
|
||||
_isPortalEnabled = false;
|
||||
_lastUsed = Time.time;
|
||||
linkedPortal._lastUsed = Time.time;
|
||||
|
||||
Debug.Log("Cooldown started");
|
||||
|
||||
other.transform.position = new Vector3(linkedPortal.transform.position.x, other.transform.position.y, linkedPortal.transform.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_justUsed)
|
||||
{
|
||||
if (_lastUsed + _portalCooldown < Time.time)
|
||||
{
|
||||
Debug.Log("Portals enabled again");
|
||||
_isPortalEnabled = true;
|
||||
linkedPortal._isPortalEnabled = true;
|
||||
_justUsed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/BasicPortal.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/BasicPortal.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aec976f8f6a93554a99ac77b05f6d030
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
144
Assets/Project Files/Scripts/JonasB/Dash.cs
Normal file
144
Assets/Project Files/Scripts/JonasB/Dash.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
public class Dash : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float minDashRange = 0.5f;
|
||||
[SerializeField]
|
||||
private float maxDashRange = 40f;
|
||||
[SerializeField]
|
||||
private float dashTime = 0.2f;
|
||||
|
||||
private Transform cameraRigRoot;
|
||||
public XRNode dashSource;
|
||||
public InputHelpers.Button dashButton;
|
||||
private float inputThreshold = 0.1f;
|
||||
|
||||
public float vignetteIntensity = 0.75f;
|
||||
public float abberationIntensity = 0.75f;
|
||||
public float duration = 0.5f;
|
||||
public Volume volume = null;
|
||||
private Transform rController;
|
||||
|
||||
private ParticleSystem trail;
|
||||
private Vignette vignette = null;
|
||||
private ChromaticAberration aberration = null;
|
||||
|
||||
public AudioClip dashFX;
|
||||
private bool _canDash = true;
|
||||
private bool _justDashed = false;
|
||||
private float _lastUsed;
|
||||
private float _dashCooldown = 3.0f;
|
||||
AudioSource audioPlayer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
trail = transform.Find("Trail").GetComponent<ParticleSystem>();
|
||||
rController = GameObject.Find("RightHand Controller").transform;
|
||||
cameraRigRoot = transform;
|
||||
if (volume.profile.TryGet(out Vignette vignette))
|
||||
{
|
||||
this.vignette = vignette;
|
||||
vignette.smoothness.Override(0.4f);
|
||||
}
|
||||
if (volume.profile.TryGet(out ChromaticAberration aberration))
|
||||
{
|
||||
this.aberration = aberration;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(dashSource), dashButton, out bool isPressed, inputThreshold);
|
||||
if (isPressed && _canDash)
|
||||
{
|
||||
TryDash();
|
||||
}
|
||||
|
||||
if (_justDashed)
|
||||
{
|
||||
if (_lastUsed + _dashCooldown < Time.time)
|
||||
{
|
||||
_justDashed = false;
|
||||
_canDash = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void TryDash()
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = new Ray(rController.position, rController.forward);
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
Debug.Log(hit);
|
||||
if (hit.distance > minDashRange && hit.distance < maxDashRange)
|
||||
{
|
||||
_canDash = false;
|
||||
_justDashed = true;
|
||||
_lastUsed = Time.time;
|
||||
StartCoroutine(FadeAndAbbr(0, vignetteIntensity, 0, abberationIntensity));
|
||||
StartCoroutine(DoDash(hit.point));
|
||||
StartCoroutine(ExecuteAfterTime(1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator DoDash(Vector3 endPoint)
|
||||
{
|
||||
|
||||
float elapsed = 0f;
|
||||
AudioSource.PlayClipAtPoint(dashFX, transform.position, 1);
|
||||
Vector3 startPoint = cameraRigRoot.position;
|
||||
trail.Play();
|
||||
while (elapsed < dashTime)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float elapsedPct = elapsed / dashTime;
|
||||
cameraRigRoot.position = Vector3.Lerp(startPoint, endPoint, elapsedPct);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ExecuteAfterTime(float time)
|
||||
{
|
||||
yield return new WaitForSeconds(time);
|
||||
|
||||
// Code to execute after the delay
|
||||
StartCoroutine(FadeAndAbbr(vignetteIntensity, 0, abberationIntensity, 0));
|
||||
}
|
||||
|
||||
private IEnumerator FadeAndAbbr(float VstartValue, float VendValue, float CAstartValue, float CAendValue)
|
||||
{
|
||||
float elapsedTime = 0.0f;
|
||||
|
||||
while (elapsedTime <= duration)
|
||||
{
|
||||
float blend = elapsedTime / duration;
|
||||
elapsedTime += Time.deltaTime;
|
||||
|
||||
float Vintensity = Mathf.Lerp(VstartValue, VendValue, blend);
|
||||
float CAintensity = Mathf.Lerp(CAstartValue, CAendValue, blend);
|
||||
ApplyValue(Vintensity, CAintensity);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
}
|
||||
|
||||
private void ApplyValue(float vignette, float cromabbr)
|
||||
{
|
||||
this.vignette.intensity.Override(vignette);
|
||||
aberration.intensity.Override(cromabbr);
|
||||
}
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/Dash.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/Dash.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70ac55ae15305574e90d87fc3cb55a51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMotion : MonoBehaviour
|
||||
public class OLD_PlayerMotion : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject OVRPlayerControllerGameObject = null;
|
||||
[SerializeField] private Transform LeftHandAnchorTransform = null;
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class TeleportationManager : MonoBehaviour
|
||||
public class OLD_TeleportationManager : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private InputActionAsset actionAsset;
|
||||
114
Assets/Project Files/Scripts/JonasB/PortalBlue.prefab
Normal file
114
Assets/Project Files/Scripts/JonasB/PortalBlue.prefab
Normal file
@@ -0,0 +1,114 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &4539673227804857418
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4539673227804857419}
|
||||
- component: {fileID: 4539673227804857422}
|
||||
- component: {fileID: 4539673227804857421}
|
||||
- component: {fileID: 4539673227804857420}
|
||||
- component: {fileID: 773644287416168023}
|
||||
m_Layer: 0
|
||||
m_Name: PortalBlue
|
||||
m_TagString: Portal
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4539673227804857419
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4539673227804857418}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -2.4029408, y: -4.8861437, z: 12.954528}
|
||||
m_LocalScale: {x: 3, y: 3, z: 0.15}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &4539673227804857422
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4539673227804857418}
|
||||
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &4539673227804857421
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4539673227804857418}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 5e53c7a8c2e563c4c90a8fa620eebc2c, 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: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!65 &4539673227804857420
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4539673227804857418}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 2, z: 0.99999994}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &773644287416168023
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4539673227804857418}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aec976f8f6a93554a99ac77b05f6d030, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
linkedPortal: {fileID: 0}
|
||||
_portalCooldown: 5
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbb86df44c735314fbab337da0d61993
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/Project Files/Scripts/JonasB/PortalOrange.prefab
Normal file
113
Assets/Project Files/Scripts/JonasB/PortalOrange.prefab
Normal file
@@ -0,0 +1,113 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &7915190915784568439
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7915190915784568436}
|
||||
- component: {fileID: 7915190915784568427}
|
||||
- component: {fileID: 7915190915784568426}
|
||||
- component: {fileID: 7915190915784568437}
|
||||
- component: {fileID: 1725384461310550779}
|
||||
m_Layer: 0
|
||||
m_Name: PortalOrange
|
||||
m_TagString: Portal
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7915190915784568436
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7915190915784568439}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 2.4970589, y: -4.8861437, z: -33.015472}
|
||||
m_LocalScale: {x: 3, y: 3, z: 0.15}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &7915190915784568427
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7915190915784568439}
|
||||
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &7915190915784568426
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7915190915784568439}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31cce59a5784d22409cb8fc86a99f275, 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: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!65 &7915190915784568437
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7915190915784568439}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 2, z: 0.99999994}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1725384461310550779
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7915190915784568439}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aec976f8f6a93554a99ac77b05f6d030, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
linkedPortal: {fileID: 0}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc38bfc5b2060a248b457329c9863b86
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/Project Files/Scripts/JonasB/PortalTeleporter.cs
Normal file
110
Assets/Project Files/Scripts/JonasB/PortalTeleporter.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PortalTeleporter : MonoBehaviour
|
||||
{
|
||||
//public Transform player;
|
||||
[SerializeField] private PortalTeleporter linkedPortal;
|
||||
private Transform linkedPortalTransform;
|
||||
private float _portalCooldown = 2.5f;
|
||||
private bool _travellerIsOverlapping = false;
|
||||
private bool _portalIsEnabled;
|
||||
private float _lastUsed;
|
||||
private bool _justUsed;
|
||||
private Transform traveller;
|
||||
public AudioClip TeleportSound;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
linkedPortalTransform = linkedPortal.transform;
|
||||
_portalIsEnabled = true;
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
traveller = other.gameObject.transform;
|
||||
if (_portalIsEnabled && !_justUsed)
|
||||
{
|
||||
linkedPortal._portalIsEnabled = false;
|
||||
_travellerIsOverlapping = true;
|
||||
if (other.tag == "Throwable")
|
||||
{
|
||||
Debug.Log("Portal entered by throwable");
|
||||
HandleThrowable();
|
||||
}
|
||||
else if (other.tag == "Player")
|
||||
{
|
||||
Debug.Log("Portal entered by player");
|
||||
HandlePlayer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void HandlePlayer()
|
||||
{
|
||||
Vector3 portalToTraveller = traveller.position - transform.position;
|
||||
float dotProduct = Vector3.Dot(transform.up, portalToTraveller);
|
||||
// If true player is on right side of portal
|
||||
if (dotProduct < 0f)
|
||||
{
|
||||
// teleport player
|
||||
float rotationDiff = -Quaternion.Angle(transform.rotation, linkedPortalTransform.rotation);
|
||||
rotationDiff += 180;
|
||||
traveller.Rotate(Vector3.up, rotationDiff);
|
||||
Vector3 positionOffset = Quaternion.Euler(0f, rotationDiff, 0f) * portalToTraveller;
|
||||
traveller.position = linkedPortalTransform.position + positionOffset;
|
||||
AudioSource.PlayClipAtPoint(TeleportSound, traveller.position, 1);
|
||||
_travellerIsOverlapping = false;
|
||||
_portalIsEnabled = false;
|
||||
_lastUsed = Time.time;
|
||||
_justUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleThrowable()
|
||||
{
|
||||
Vector3 portalToTraveller = traveller.position - transform.position;
|
||||
float dotProduct = Vector3.Dot(transform.up, portalToTraveller);
|
||||
// If true player is on right side of portal
|
||||
if (dotProduct < 0f)
|
||||
{
|
||||
// teleport player
|
||||
AudioSource.PlayClipAtPoint(TeleportSound, this.transform.position, 1);
|
||||
float rotationDiff = -Quaternion.Angle(transform.rotation, linkedPortalTransform.rotation);
|
||||
rotationDiff += 180;
|
||||
traveller.Rotate(Vector3.up, rotationDiff);
|
||||
Vector3 positionOffset = Quaternion.Euler(0f, rotationDiff, 0f) * portalToTraveller;
|
||||
traveller.position = linkedPortalTransform.position + positionOffset;
|
||||
_travellerIsOverlapping = false;
|
||||
_portalIsEnabled = false;
|
||||
_lastUsed = Time.time;
|
||||
_justUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.tag == "Player" || other.tag == "Throwable")
|
||||
{
|
||||
_travellerIsOverlapping = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_justUsed)
|
||||
{
|
||||
if (_lastUsed + _portalCooldown < Time.time)
|
||||
{
|
||||
_justUsed = false;
|
||||
_portalIsEnabled = true;
|
||||
linkedPortal._portalIsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/PortalTeleporter.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/PortalTeleporter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a378270e273afb42af6176a50891130
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -10,12 +10,13 @@ public class SpawnerGestureInteraction : MonoBehaviour
|
||||
|
||||
public void SpawnObject(string objectName)
|
||||
{
|
||||
Debug.Log(objectName);
|
||||
|
||||
foreach (var item in objects)
|
||||
{
|
||||
if (item.name == objectName)
|
||||
{
|
||||
Instantiate(item, rightHandTransform.position, Quaternion.identity);
|
||||
Debug.Log(objectName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
67
Assets/Project Files/Scripts/JonasB/VignetteApplier.cs
Normal file
67
Assets/Project Files/Scripts/JonasB/VignetteApplier.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class VignetteApplier : MonoBehaviour
|
||||
{
|
||||
public float intensity = 0.75f;
|
||||
public float duration = 0.5f;
|
||||
public Volume volume = null;
|
||||
|
||||
public LocomotionProvider locomotionProvider;
|
||||
private Vignette vignette = null;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
if (volume.profile.TryGet(out Vignette vignette))
|
||||
{
|
||||
this.vignette = vignette;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
locomotionProvider.beginLocomotion += FadeIn;
|
||||
locomotionProvider.endLocomotion += FadeOut;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
locomotionProvider.beginLocomotion -= FadeIn;
|
||||
locomotionProvider.endLocomotion -= FadeOut;
|
||||
}
|
||||
|
||||
public void FadeIn(LocomotionSystem locomotion)
|
||||
{
|
||||
StartCoroutine(Fade(0, intensity));
|
||||
}
|
||||
public void FadeOut(LocomotionSystem locomotion)
|
||||
{
|
||||
StartCoroutine(Fade(intensity, 0));
|
||||
}
|
||||
|
||||
private IEnumerator Fade(float startValue, float endValue)
|
||||
{
|
||||
float elapsedTime = 0.0f;
|
||||
|
||||
while (elapsedTime <= duration)
|
||||
{
|
||||
float blend = elapsedTime / duration;
|
||||
elapsedTime += Time.deltaTime;
|
||||
|
||||
float intensity = Mathf.Lerp(startValue, endValue, blend);
|
||||
Debug.Log(intensity);
|
||||
ApplyValue(intensity);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
private void ApplyValue(float value)
|
||||
{
|
||||
vignette.intensity.Override(value);
|
||||
}
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/VignetteApplier.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/VignetteApplier.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db9d8031d089f334194322c30b894ed5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user