I don’t know how to implement relationship of velocity and distance correctly. I have generator of platforms, when a player(ball) get to the end of platforms, player jump to the next. At the same time generator create a new platform. Velocity of player , straightforce (for jump) and distance between platforms are constant. But i want to increase velocity after 5 covered platforms and i dont relationship between increasing velocity and distance between platform.
//Spawnscript
private float offset = 20.8277f;
private float zpos = 104.1335f;
void OnTriggerEnter(Collider other)
if (kk != 6)
{
if (other.tag == "jump")
{
zpos += set;
if ((kk % 9) != 0)
{
plt[(kk % 10)] = Instantiate(obj, Vector3.forward * zpos, Quaternion.identity);
}
else
{
plt[(kk % 10)] = Instantiate(obj10, Vector3.forward * zpos, Quaternion.identity) as GameObject;
}
//Script for movement:
private float straightforce = 3f
private float force = 3000f
private float gravity = 6.8f, gravitymax = 15f;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
rb.velocity = new Vector3(0, 0, straightforce);
}
void Update()
{
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "jump")
{
rb.AddForce(0, force, 0);
}
}
}