Unity/Trial & Error

[Unity][Trial&Error] 오브젝트를 grab 후 release할 때 아래로 빠르게 떨어지는 현상

_GyC_ 2023. 1. 20. 18:01

먼저, Oculus Integration SDK를 사용하여 물체를 grab하는 방법은 다음 글을 참고하라.

https://gycblog.tistory.com/6

 

[Unity] Player Grab Interaction with Oculus Integration SDK

[Interaction Setting - InputOVR] 1. Hierarchy에 InputOVR을 추가한다. *InputOVR을 못찾겠거나 InputOVR이 있지만 비어있으면 아래 블로그 글을 참고하자. 더보기 https://gycblog.tistory.com/3 [Unity][Trial&Error] Assets에서 In

gycblog.tistory.com

 

위 글대로 오브젝트를 grab하는 것에 성공했지만, 오브젝트의 rigidbody가 중력을 받고 있고 kinematic이 아닌 경우에는 grab했다가 release하면 아래로 빠르게 떨어지거나 땅을 뚫고 떨어진다. 일반 오브젝트같지 않은 부자연스러움이다.


Problem: Grab한 오브젝트를 release하면 아래로 빠르게 떨어지거나 땅을 뚫고 떨어진다.

Solution: Oculus Integration SDK에서 제공하는 Physics Grabbable 스크립트를 사용한다.

Grab하려는 오브젝트에는 기본적으로 Grabbable과 Grab Interactable 또는 Hand Grab Interactable 등이 있다. 여기서 Physics Grabble 스크립트를 추가하고 Grab Interactable의 Physics Grabbable 부분에 해당 스크립트를 reference해주면 된다.

Physics Grabbable

 

이렇게 Pointable Element에는 Grabbable, Rigidbody에는 오브젝트의 Rigidbody, 그리고 Physics Grabbable에는 Physics Grabbable 스크립트를 reference를 하면 된다.


Physics Grabbable이 없는 경우:

 

Physics Grabbable이 있는 경우:

더 자연스럽게 떨어지는 것을 볼 수 있다.