mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Fixes #314
This commit is contained in:
parent
d9e9e2b5cf
commit
7732a63b5a
30
QSB/ConversationSync/CameraFacingBillboard.cs
Normal file
30
QSB/ConversationSync/CameraFacingBillboard.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraFacingBillboard : MonoBehaviour
|
||||
{
|
||||
private OWCamera _activeCam;
|
||||
|
||||
private void Awake()
|
||||
=> GlobalMessenger<OWCamera>.AddListener("SwitchActiveCamera", OnSwitchActiveCamera);
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_activeCam = Locator.GetActiveCamera();
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
=> GlobalMessenger<OWCamera>.RemoveListener("SwitchActiveCamera", OnSwitchActiveCamera);
|
||||
|
||||
private void OnSwitchActiveCamera(OWCamera activeCamera)
|
||||
{
|
||||
_activeCam = activeCamera;
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
=> UpdateRotation();
|
||||
|
||||
private void UpdateRotation()
|
||||
=> transform.LookAt(transform.position + (_activeCam.transform.rotation * Vector3.forward), _activeCam.transform.rotation * Vector3.up);
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Events;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
@ -120,10 +119,7 @@ namespace QSB.ConversationSync
|
||||
newBox.transform.SetParent(parent);
|
||||
newBox.transform.localPosition = new Vector3(0, vertOffset, 0);
|
||||
newBox.transform.rotation = parent.rotation;
|
||||
var lookAt = newBox.AddComponent<FaceActiveCamera>();
|
||||
lookAt.SetValue("_useLookAt", false);
|
||||
lookAt.SetValue("_localFacingVector", Vector3.back);
|
||||
lookAt.SetValue("_localRotationAxis", Vector3.up);
|
||||
newBox.AddComponent<CameraFacingBillboard>();
|
||||
newBox.GetComponent<Text>().text = text;
|
||||
newBox.AddComponent<ZOverride>();
|
||||
newBox.SetActive(true);
|
||||
|
@ -134,6 +134,7 @@
|
||||
<Compile Include="CampfireSync\WorldObjects\QSBCampfire.cs" />
|
||||
<Compile Include="ClientServerStateSync\ClientStateManager.cs" />
|
||||
<Compile Include="ClientServerStateSync\Events\ClientStateEvent.cs" />
|
||||
<Compile Include="ConversationSync\CameraFacingBillboard.cs" />
|
||||
<Compile Include="ConversationSync\Events\DialogueConditionEvent.cs" />
|
||||
<Compile Include="ConversationSync\Events\DialogueConditionMessage.cs" />
|
||||
<Compile Include="ConversationSync\Events\ConversationEvent.cs" />
|
||||
|
@ -1,5 +1,4 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -29,10 +28,7 @@ namespace QSB.Utility
|
||||
newBox.transform.SetParent(parent);
|
||||
newBox.transform.localPosition = new Vector3(0, vertOffset, 0);
|
||||
newBox.transform.rotation = parent.rotation;
|
||||
var lookAt = newBox.AddComponent<FaceActiveCamera>();
|
||||
lookAt.SetValue("_useLookAt", true);
|
||||
lookAt.SetValue("_localFacingVector", Vector3.back);
|
||||
lookAt.SetValue("_localRotationAxis", Vector3.up);
|
||||
newBox.AddComponent<CameraFacingBillboard>();
|
||||
newBox.GetComponent<Text>().text = text;
|
||||
newBox.AddComponent<ZOverride>();
|
||||
newBox.SetActive(true);
|
||||
|
Loading…
Reference in New Issue
Block a user