Added keyslot compatibility Frames look at when you look away Fixed snow globes
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using Unity.Netcode;
|
|
using GameNetcodeStuff;
|
|
|
|
namespace ScarletMansion.GamePatch.Components {
|
|
public class ScarletFrame : MonoBehaviour {
|
|
|
|
public float visualUpdate = 0.2f;
|
|
private float visualUpdateCurrent = 0f;
|
|
|
|
void Start(){
|
|
visualUpdateCurrent = UnityEngine.Random.value * visualUpdate;
|
|
}
|
|
|
|
void Update() {
|
|
visualUpdateCurrent += Time.deltaTime;
|
|
if (visualUpdateCurrent > visualUpdate) {
|
|
LookAtLocalPlayer();
|
|
visualUpdateCurrent = 0f;
|
|
}
|
|
}
|
|
|
|
void LookAtLocalPlayer(){
|
|
var localPlayer = StartOfRound.Instance.localPlayerController;
|
|
if (localPlayer && !localPlayer.isPlayerDead) {
|
|
var direction = localPlayer.transform.position - transform.position;
|
|
direction.y = 0f;
|
|
direction = direction.normalized;
|
|
|
|
var playerFacing = -localPlayer.gameplayCamera.transform.forward;
|
|
|
|
// only face player when player looking away
|
|
if (Vector3.Dot(playerFacing, direction) < 0.25f) {
|
|
transform.rotation = Quaternion.LookRotation(direction);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|