Added Observation Scene to show the Replay

This commit is contained in:
Thorbjoern
2025-05-26 18:56:25 +02:00
parent 37c6bd8269
commit c304bc0e10
211 changed files with 60070 additions and 14 deletions
@@ -0,0 +1,31 @@
using UnityEngine;
namespace Unity.Cinemachine.Samples
{
/// <summary>This behaviour works in conjunction with PlayerOnSurface to keep the player
/// parented to the surface it's standing on. This is useful to prevent sliding
/// when the surface is in motion</summary>
[RequireComponent(typeof(SimplePlayerOnSurface))]
public class ReparentPlayerToSurface : MonoBehaviour
{
SimplePlayerOnSurface m_PlayerOnSurface;
void OnEnable()
{
if (TryGetComponent(out m_PlayerOnSurface))
m_PlayerOnSurface.SurfaceChanged.AddListener(OnSurfaceChanged);
}
void OnDisable()
{
if (m_PlayerOnSurface != null)
m_PlayerOnSurface.SurfaceChanged.RemoveListener(OnSurfaceChanged);
}
// newSurface may be null, in which case we should just uparent the player
void OnSurfaceChanged(Collider newSurface)
{
transform.SetParent(newSurface == null ? null : newSurface.transform, true);
}
}
}