Created
February 25, 2021 21:38
-
-
Save andybak/1aef7ee80b94a5ba6afb087f89ef50aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class SetTrackOffsetPositionOnRelease : MonoBehaviour | |
{ | |
public GameObject feet; | |
public Transform target; | |
void OnEnable() | |
{ | |
MoveToTarget(); | |
} | |
public void MoveToTarget() | |
{ | |
var feetToTargetVector = feet.transform.position - target.position; | |
transform.parent.transform.position = transform.parent.transform.position - feetToTargetVector; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment