2021년 4학년 1학기 기업연계프로젝트2
컴퓨터소프트웨어공학과 <원광투어팀>
팀장 : 송유진
팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System.Collections;using System.Collections.Generic;using UnityEngine;
namespace Valve.VR.InteractionSystem.Sample{ public class LockToPoint : MonoBehaviour { public Transform snapTo; private Rigidbody body; public float snapTime = 2;
private float dropTimer; private Interactable interactable;
private void Start() { interactable = GetComponent<Interactable>(); body = GetComponent<Rigidbody>(); }
private void FixedUpdate() { bool used = false; if (interactable != null) used = interactable.attachedToHand;
if (used) { body.isKinematic = false; dropTimer = -1; } else { dropTimer += Time.deltaTime / (snapTime / 2);
body.isKinematic = dropTimer > 1;
if (dropTimer > 1) { //transform.parent = snapTo;
transform.position = snapTo.position; transform.rotation = snapTo.rotation; } else { float t = Mathf.Pow(35, dropTimer);
body.velocity = Vector3.Lerp(body.velocity, Vector3.zero, Time.fixedDeltaTime * 4); if (body.useGravity) body.AddForce(-Physics.gravity);
transform.position = Vector3.Lerp(transform.position, snapTo.position, Time.fixedDeltaTime * t * 3); transform.rotation = Quaternion.Slerp(transform.rotation, snapTo.rotation, Time.fixedDeltaTime * t * 2); } } } }}
|