Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
7 years ago
Is there a way of changing speed of an object at certain time? I want to change my speed to my initial speed after colliding with any object. I have already added bounce Physics to my colliding objects and player object with Friction set to 0. Please help.
Jun 4, 2016 at 12:55
Get the Rigidbody component. Then change the velocity value.
rb = GetComponent<Rigidbody>();
rb.velocity = new vector3(x,y,z); //place your value in xyz
For further reference:
Unity Physics Rigidbody Velocity
Jun 4, 2016 at 13:01
Sourav Paul Roman Sourav Paul Roman
2,033 2 2 gold badges 14 14 silver badges 20 20 bronze badges
You could apply a force opposite to it for decceleration or a force in the movement direction for acceleration.
GetComponent<Rigidbody>().AddForce(transform.forward * FORCE_CONSTANT);
or for desceleration:
GetComponent<Rigidbody>().AddForce(-transform.forward * FORCE_CONSTANT);
Apr 6, 2017 at 18:11
John Smith John Smith
1,235 1 1 gold badge 20 20 silver badges 39 39 bronze badges
log in to answer this question.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only