Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Mathf.Sqrt(Mathf.Pow(xDist, 2) + Mathf.Pow(yDist, 2)) <= 80f)
- {
- xDist = follow.transform.position.x - transform.position.x;
- yDist = follow.transform.position.y - transform.position.y;
- }
- else {
- //transform.position = Vector3.Lerp (transform.position)
- transform.position = new Vector3(Mathf.RoundToInt(follow.transform.position.x - xDist), Mathf.RoundToInt(follow.transform.position.y - yDist), transform.position.z);
- if (xDist > 0)
- {
- xDist -= 0.25f * Time.deltaTime * 60f;
- }
- else if (xDist < 0)
- {
- xDist += 0.25f * Time.deltaTime * 60f;
- }
- if (yDist > 0)
- {
- yDist -= 0.25f * Time.deltaTime * 60f;
- }
- else if (yDist < 0)
- {
- yDist += 0.25f * Time.deltaTime * 60f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement