Question by
Luiz_Thiago · Dec 26, 2019 at 07:20 PM ·
rotationmathcoordinatescoordinate-system
Problems with rotation when I try to create a offset system with Handles.PositionHandle
Hello people,
I'm trying to create an offset system for my objects, and I'm using Handles.PositionHandle for this... Everything was going well, until I decided to rotate the object... The handle just doesn't "follow the rotation" of the object, and seems to follow a rotation based on (0,0,0) of the world.
Could someone guide me? A link for the video of the problem: https://youtu.be/oMzGvwxY2YI
protected virtual void OnSceneGUI()
{
Bvu_Grabbable grabbable = (Bvu_Grabbable)target;
if (useOffset.boolValue)
{
EditorGUI.BeginChangeCheck();
var newOffset =
Handles.PositionHandle(grabbable.transform.InverseTransformDirection
(
grabbable.transform.position + grabbable.positionOffset), Quaternion.identity
);
if (EditorGUI.EndChangeCheck())
{
grabbable.positionOffset =
grabbable.transform.TransformDirection(newOffset - grabbable.transform.position);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Help with suns rotation 0 Answers
How can I use Mathf.Clamp? 1 Answer
Predict the hit position 0 Answers
Math: How to rotate a wheel by drag&drop (Canvas, 2D)? 0 Answers
How do you rotate a rigidbody while maintaining world-coordinate velocity? 0 Answers