I need bone1 to follow a certain point how to do it ?
Bone1 is a child of bone2.
This should probably work if not please tell me!
using UnityEngine;
using System.Collections;
public class BoneMovement : MonoBehaviour
{
public Transform bone1;
//The Target Position.
public Transform target;
// Speed In Units Per Second.
public float speed;
void Start()
{
//gets the bones transform
bone1 = GetComponent<Transform>();
}
void Update()
{
bone1.position = Vector3.MoveTowards(bone1.position, target, speed*Time.deltatime);
}
}
That’s what i used
C#
x1 = RightHand.transform.localPosition.z * -1;
x2 = RightHandMove.transform.localPosition.z * -1;
float x3 = RightHandMove.transform.localPosition.z * -1;
y1 = RightHand.transform.localPosition.y * -1;
y2 = (RightHandMove.transform.localPosition.y * -1) + (float)0.0061083;
float y3 = RightHand.transform.localPosition.y * -1;
float c1start = Mathf.Pow((x2 - x1),2) + Mathf.Pow((y2 - y1), 2);
float b1start = Mathf.Pow((x3 - x1),2) + Mathf.Pow((y3 - y1), 2);
c1 = Mathf.Sqrt(c1start);
b1 = Mathf.Sqrt(b1start);
float A = (Mathf.Acos(b1 / c1)) * (float)57.295779513082320876798154814105;
if (y2 > 0 && x2 >0)
{
Bone8.transform.localRotation = Quaternion.Euler((A + 90) * -1, 0, 0);
}
else if (y2 < 0 && x2 < 0)
{
Bone8.transform.localRotation = Quaternion.Euler((A - 90) * -1, 0, 0);
}
else if (y2 > 0 && x2 < 0)
{
Bone8.transform.localRotation = Quaternion.Euler(A + 90, 0, 0);
}
else if (y2 < 0 && x2 > 0)
{
Bone8.transform.localRotation = Quaternion.Euler(A - 90, 0, 0);
}