Question by
Taek16 · Sep 28, 2020 at 09:01 PM ·
2dlerpchild object
How do you lerp a child of an object while the object is moving?
So, I am new to lerping and I am working on a script to attach an object "currentNode" to the object this script is on using lerp function for both position and rotation. However, nothing is working and the object instantly warps, and it doesn't even warp to the center of the parent with the offset like it should. Can I have some help here?
if (hit.distance < maximumDistance && !isAttatched)
{
currentNodeRb = currentNode.GetComponent<Rigidbody2D>();
currentNodeRb.isKinematic = true;
currentNode.transform.parent = transform;
currentNode.transform.rotation = Quaternion.Lerp(currentNode.transform.rotation, transform.rotation, Time.deltaTime);
currentNode.transform.localPosition = Vector3.Lerp(currentNode.transform.localPosition, Vector3.zero + offset, Time.deltaTime);
isAttatched = true;
}
Comment