mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
1d35e88533
* Freeze Frame Hey, I'm about done with Freeze Frame and I'm just gonna commit the game as it is right now, it's almost done thx -playinful * Freeze Frame - finishing touches before finalized assets Still waiting to implement the upscaled assets and the sound effects. Code-wise this is as much as I can do for now. * i fixed a couple bugs the dim screen is back and no input duplication when switching games. hallelujah * FreezeFrame randomness update hey AJ so i was cleaning my room when i was struck by an idea for how to make the randomization more consistent without seeding. *yes unfortunately* it requires a static variable but i promise u i used it responsibly.
44 lines
No EOL
1.3 KiB
C#
44 lines
No EOL
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Common
|
|
{
|
|
public class StickyCanvas : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Attach to a GameObject to make the object follow the camera while also moving with the viewport.
|
|
/// Can be enabled or disabled.
|
|
/// May malfunction when rescaled.
|
|
/// </summary>
|
|
private Vector3 _OriginalPosition;
|
|
private Quaternion _OriginalRotation;
|
|
|
|
[SerializeField] public bool Sticky = true;
|
|
[SerializeField] float CameraOffset = 10;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
_OriginalPosition = transform.position;
|
|
_OriginalRotation = transform.rotation;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (!Sticky)
|
|
{
|
|
transform.position = _OriginalPosition;
|
|
transform.rotation = _OriginalRotation;
|
|
return;
|
|
}
|
|
|
|
if (Conductor.instance == null) return;
|
|
Transform target = GameCamera.instance.transform;
|
|
|
|
Vector3 displacement = target.forward * CameraOffset;
|
|
transform.position = target.position + displacement;
|
|
transform.rotation = target.rotation;
|
|
}
|
|
}
|
|
} |