using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereRadin : MonoBehaviour {
List<Vector3> posList = new List<Vector3>();
public float journeyTime = 3.0f;
// The time at which the animation started.
private float startTime;
private float runningTime, percentage,radin;
private Vector3 startPos;
private Vector3 endPos;
public LineRenderer line;
private Vector3 centerPos;
void Awake()
{
startTime = Time.time;
}
private void FixedUpdate()
{
runningTime += Time.deltaTime;
percentage = runningTime / journeyTime;
radin = Mathf.Sin(Mathf.PI * percentage) + 1f;
if (percentage > 1)
{
return;
}
Vector3 riseRelCenter = startPos - centerPos;
Vector3 setRelCenter = endPos - centerPos;
transform.position = Vector3.Slerp(riseRelCenter * radin, setRelCenter * radin, percentage);
transform.position += centerPos;
posList.Add(transform.position);
line.positionCount = posList.Count;
line.SetPositions(posList.ToArray());
}
}