I have some trouble to do a Recoil routine. I've a Tank, a turret cannon on it. I want that after shot, turret fast recoil back, than (slowly) get back to start position.
This is the code I've tought but obviously it not works.
Update () {
if(shot) {
Shot();
TurretBackRecoil();
}
}
private void TurretBackRecoil() {
transform.Translate(new Vector3(0,-10,0) * Time.deltaTime * 3 );
}
private void TurretForwardRecoil () {
transform.Translate(new Vector3(0,10,0) * Time.deltaTime);
}