Need help with stopping velocity after a sphere reaches a certain velocity

My issue is in LateUpdate I’m honestly not even sure if the code I wrote belongs in LateUpdate. What I need to happen is when the ball reaches a certain low speed rather than continuing rolling I would like it to run the script to reset it rotation and stop it from moving so it can be fired off from it’s new position again without having to press a button to do it. Sorry about the sloppy code I am very new to this and this is my first project I am working on by myself. For a better image of what I need think of a car slowing down from 50 Mph but once it reaches lets say 5Mph rather than slowing down from 5-0 it just stops dead in it tracks. Thank you for any help!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class BallControl : MonoBehaviour
{

public float zForce = 20f;
public Slider Slider;
public Image FillImage;
public Color Zero = Color.green;
public Color Twentyfive = Color.black;
public Color Fifty = Color.yellow;
public Color Seventyfive = Color.black;
public Color Hundred = Color.red;

void Start ()
{
Slider.value = zForce;
}

void FixedUpdate ()
{

}

void Update ()
{

if (Input.GetButtonDown (“Fire1”))
{
GetComponent ().AddRelativeForce (0, 0, zForce);
}

if (Input.GetKey(“a”))
{
transform.Rotate (0, -1, 0);
}

if (Input.GetKey(“d”))
{
transform.Rotate (0, 1, 0);
}

if (Input.GetKey (“w”))
{
zForce += 4;
Slider.value += 4;
}

if (Input.GetKey (“s”))
{
zForce -= 4;
Slider.value -= 4;
}

if (zForce < 20)
{
zForce = 20;
}

if (zForce > 2000)
{
zForce = 2000;
}

if (zForce == 1980)
{
FillImage.color = Hundred;
}

if (zForce == 1500)
{
FillImage.color = Seventyfive;
}

if (zForce == 1000)
{
FillImage.color = Fifty;
}

if (zForce == 500)
{
FillImage.color = Twentyfive;
}

if (zForce == 20)
{
FillImage.color = Zero;
}
}

void LateUpdate()
{
/if (Not sure what to place here or even if it is right)
{
GetComponent ().velocity = new Vector3 (0, 0, 0);
GetComponent ().angularVelocity = new Vector3 (0, 0, 0);
GetComponent().eulerAngles = new Vector3(0, 0, 0);
}
/
}

void OnTriggerEnter(Collider other)
{
if (other.name == “WinTrigger”)
{
GetComponent().velocity = new Vector3 (0,0,0);
Debug.Log (“Completed!”);
StartCoroutine (delayLoad ());
}
}

void OnTriggerExit(Collider other)
{
if (other.name == “Exit”)
{
StartCoroutine (delayExit ());
}
}

IEnumerator delayExit()
{
yield return new WaitForSeconds (1);
SceneManager.LoadScene (“_Main”);
}

IEnumerator delayLoad()
{
yield return new WaitForSeconds (2);
SceneManager.LoadScene (“_Main”);
}

}

3067703–230613–BallControl.cs (2.19 KB)

There is a pinned thread about how to add code posts to the forums (properly). Please read that. People are much more likely to help you (and read it, to begin with) when you use those.

Okay, so your issue… Does the car only ever go on the z-axis? The only force I see is there, I think…

Seems like you have it rotate with a couple of keys, but the momentum is always forward… In case that’s right, you can check for : rigidbody.velocity.z (and compare, I would think).