constantly jumping using Slerp
Hey guys! Im trying to make an object jump forward for a certain distance. And cant figure this out... I tried adding force but the jump distance would increase with every jump. Now i am trying to do this with slerp. But i cant find a way to use this for jumping constantly forward.... Any help would be appreciated This is my current Code:
public GameObject ThePlayer;
public Transform PlayerStart;
public Transform PlayerEnd;
float Temp = 10f;
public float speed = 1.0f;
public float lenght = 1.0f;
private float startTime;
void FixedUpdate () {
Vector3 center = (PlayerStart.position + PlayerEnd.position) * 0.5f;
center -= new Vector3(0, 1, 0);
Vector3 startRelCenter = PlayerStart.position - center;
Vector3 endRelCenter = PlayerEnd.position - center;
float fracComplete = (Time.time - startTime) / lenght * speed; //Viena Karta
transform.position = Vector3.Slerp(startRelCenter, endRelCenter, fracComplete);
transform.position += center;
// PlayerStart.position = new Vector3(0, 1.08f, Temp);
// PlayerEnd.position = new Vector3(0, 1.08f, Temp + 10);
// Temp += 10;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612183843im_/https://answers.unity.com/themes/thub/images/avi.jpg)