- Home /
grasp object over a predefined path.
Hi,
I'm using Leapmotion to grasp an object. It must follow a predefined path. So there's a start position and an end position. When grasping begins, the distance between start position and current position is the current distance. When grasping if activated, I store the begin values. After that I define whats the distance and the angle. But my solution doesn't work, because an negative angles is not equal to a negative distance.
float grasp_distance = Vector3.Distance(beginGraspPoint, graspPoint);
float grasp_angle = Vector3.Angle(beginObjectPosition, graspPoint);
float curr_grasp_obj_angle = Vector3.Angle(beginObjectPosition, graspPoint);
float diff_grasp_obj_angle = curr_grasp_obj_angle - grasp_obj_angle;
if (diff_grasp_obj_angle < 0)
grasp_distance = -grasp_distance;
float s = getSmoothGrasp(grasp_distance + beginDistance);
float maxDistance = Vector3.Distance(m_EndPosition, m_StartPosition);
float obj_angle = Vector3.Angle(m_EndPosition, m_StartPosition);
float t = (s) / maxDistance;
this.gameObject.transform.position = Vector3.Lerp(m_StartPosition, m_EndPosition, Mathf.SmoothStep(0.0f, 1.0f, t));
lastDistance = s; // this becomes beginDistance
I was wondering what is the best option to make this working?
Your answer
Follow this Question
Related Questions
Lerp in direction to certain distance 3 Answers
How can I Lerp the Rotation of my Game Object to my Mouse Pointer? 1 Answer
Finding the direction an object is moving and giving it a destination 1 Answer
Getting a position behind a target object (targeted attack follow through) 2 Answers
Camera position 1 Answer