Question by
up826703 · Mar 06, 2018 at 09:53 PM ·
c#positionoffsetbasic programmingrelative position
Offsetting object to below another constantly?
So, what I've got here, is code which finds the position of the wheel collider, and makes the position of a specific bone the same. However, because they are at the same position, they are inside each other. How do I set it up, so that the track is always below the wheel collider? (Collider radius is 0.095) So far I have looked through a series off solutions to no avail.
public class TrackBehaviour : MonoBehaviour {
public WheelCollider targetTrack;
private Vector3 trackPosition = new Vector3();
private Quaternion trackRotation = new Quaternion ();
// Update is called once per frame
void Update () {
targetTrack.GetWorldPose(out trackPosition, out trackRotation);
transform.position = trackPosition;
}
}
wheel.png
(395.0 kB)
Comment
Answer by bennett_apps · Aug 02, 2018 at 07:55 PM
Don't do this in your script...parent the track to the wheels!