NoPoints pretty much working
This commit is contained in:
44
Assets/Quiz/Scripts/Managers/TabletManager.cs
Normal file
44
Assets/Quiz/Scripts/Managers/TabletManager.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Components;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
|
||||
public class TabletManager : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject tablet;
|
||||
[SerializeField] private float spawnDistance = 2f;
|
||||
[SerializeField] private float spawnHeight = 1f;
|
||||
|
||||
[SerializeField] private VRCPickup tabletPickup;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!Networking.IsOwner(gameObject))
|
||||
{
|
||||
Destroy(tabletPickup);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.T) && Networking.IsOwner(gameObject))
|
||||
{
|
||||
SpawnTablet();
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnTablet()
|
||||
{
|
||||
// Get local player's position and rotation
|
||||
VRCPlayerApi localPlayer = Networking.LocalPlayer;
|
||||
if (localPlayer == null || tablet == null) return;
|
||||
|
||||
Vector3 spawnPos = localPlayer.GetPosition() + (localPlayer.GetRotation() * Vector3.forward) * spawnDistance + Vector3.up * spawnHeight;
|
||||
Quaternion spawnRot = localPlayer.GetRotation();
|
||||
|
||||
tablet.transform.position = spawnPos;
|
||||
tablet.transform.rotation = spawnRot;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user