Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UdonSharp;
- using UnityEngine;
- using VRC.SDKBase;
- using VRC.Udon;
- public class FlyingObject : UdonSharpBehaviour
- {
- private VRCPlayerApi playerLocal;
- private bool isActive;
- public float maxvelocity = 3;
- void Start()
- {
- playerLocal = Networking.LocalPlayer;
- }
- override public void OnPickupUseDown()
- {
- Debug.Log("set active true");
- isActive = true;
- }
- override public void OnPickupUseUp()
- {
- Debug.Log("set active false");
- isActive = false;
- }
- private void FixedUpdate()
- {
- if (isActive)
- {
- Vector3 newvel = Vector3.ClampMagnitude(playerLocal.GetVelocity() + transform.forward, maxvelocity);
- Debug.Log("setting velocity to " + newvel);
- playerLocal.SetVelocity(newvel);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement