campfire/Assets/Scripts/LinearDriveSpring.cs

17 lines
646 B
C#
Raw Normal View History

2020-06-12 21:28:40 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR.InteractionSystem;
public class LinearDriveSpring : MonoBehaviour {
public LinearDrive LinearDrive;
public Interactable Interactable;
private void Update() {
if (!Interactable.attachedToHand) {
transform.position += (LinearDrive.startPosition.position - transform.position) * 10f * Time.deltaTime;
LinearDrive.linearMapping.value = (transform.position - LinearDrive.startPosition.position).magnitude / (LinearDrive.endPosition.position - LinearDrive.startPosition.position).magnitude;
}
}
}