FX , VO, fixy
This commit is contained in:
36
Assets/Scripts/PlayerAutoRotator.cs
Normal file
36
Assets/Scripts/PlayerAutoRotator.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Beyond
|
||||
{
|
||||
public class PlayerAutoRotator : MonoBehaviour
|
||||
{
|
||||
public float rotationSpeed = 5f;
|
||||
private Transform targetToLook;
|
||||
private bool shouldRotate = false;
|
||||
|
||||
public void LookAtTarget(Transform target)
|
||||
{
|
||||
targetToLook = target;
|
||||
shouldRotate = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!shouldRotate || targetToLook == null)
|
||||
return;
|
||||
|
||||
Vector3 direction = (targetToLook.position - transform.position).normalized;
|
||||
direction.y = 0;
|
||||
|
||||
if (direction == Vector3.zero) return;
|
||||
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * rotationSpeed);
|
||||
|
||||
if (Quaternion.Angle(transform.rotation, targetRotation) < 1f)
|
||||
{
|
||||
shouldRotate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/PlayerAutoRotator.cs.meta
Normal file
2
Assets/Scripts/PlayerAutoRotator.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a8f7b2da1584ff49bdad152bbb77744
|
||||
34
Assets/Scripts/VolumeFadeOut.cs
Normal file
34
Assets/Scripts/VolumeFadeOut.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class VolumeFadeOut : MonoBehaviour
|
||||
{
|
||||
public Volume volume; // Przypisz w Inspectorze lub ustaw dynamicznie
|
||||
public float fadeDuration = 1.0f; // Czas wygaszania w sekundach
|
||||
|
||||
/// <summary>
|
||||
/// Funkcja do odpalenia z eventu, np. z przycisku lub triggera.
|
||||
/// </summary>
|
||||
public void FadeAndDisableVolume()
|
||||
{
|
||||
if (volume != null)
|
||||
StartCoroutine(FadeOutCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator FadeOutCoroutine()
|
||||
{
|
||||
float startWeight = volume.weight;
|
||||
float elapsed = 0f;
|
||||
|
||||
while (elapsed < fadeDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
volume.weight = Mathf.Lerp(startWeight, 0f, elapsed / fadeDuration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
volume.weight = 0f;
|
||||
volume.enabled = false;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/VolumeFadeOut.cs.meta
Normal file
2
Assets/Scripts/VolumeFadeOut.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8f4c5f8a982ee741b546c41519c36de
|
||||
Reference in New Issue
Block a user