mirror of
https://github.com/nothke/quality-control.git
synced 2025-09-01 08:03:43 +00:00
Added interaction, hand, rigidbody dragging, picking up hammer
This commit is contained in:
36
Assets/Plugins/Interaction/Runtime/Core/InteractableUtils.cs
Normal file
36
Assets/Plugins/Interaction/Runtime/Core/InteractableUtils.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public static class InteractableUtils
|
||||
{
|
||||
|
||||
public static Vector3 GetMousePointOnPlane(Plane plane)
|
||||
{
|
||||
Vector3 screenPoint = Input.mousePosition;
|
||||
|
||||
Ray screenRay = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
|
||||
float e = 0;
|
||||
if (plane.Raycast(screenRay, out e))
|
||||
screenPoint.z = e;
|
||||
|
||||
return screenRay.GetPoint(e);
|
||||
}
|
||||
|
||||
public static Vector3 GetJointAnchorInWorldSpace(Joint joint)
|
||||
{
|
||||
if (!joint.connectedBody) return joint.connectedAnchor;
|
||||
|
||||
return joint.connectedBody.transform.TransformPoint(joint.connectedAnchor);
|
||||
}
|
||||
|
||||
public static bool IsNonUniform(this Transform transform)
|
||||
{
|
||||
Vector3 ls = transform.lossyScale;
|
||||
return !(Mathf.Approximately(ls.x, ls.y) && Mathf.Approximately(ls.y, ls.z));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user