Hey everybody.
Here’s what I’m trying to achieve.
What’s the best way to have a rigid body gain forward speed when being dropped from height? So, for example if you just had a cube and dropped it, it would start to move forward, gaining forward speed with a nice smooth transition?
Any ideas?
Thanks in advance.
Add a velocity to it, Lerping it from 0 to Your max value:
private float SmoothConst=0.3f;
private float MaxSpeed=10f;
public Rigidbody MyCube;
void Update{
if (MyCubeIsFallingCondition){
MyCube.velocity = new Vector3(0 ,0 ,Mathf.Lerp(MyCube.velocity.z,MaxSpeed, Time.deltaTime*SmoothConst));
}
}
Note, that if it already is moving it will gain speed beginning with its current speed, othervise it will start from 0 velocity.