Increasing smth after collision (a boost mechanic)

Hi. Need a help with following C# issue.

I have an object_01 (regidbody and collider are on) which collided with another object_02 (aslo with rigidbody and collider) and after that object_01 receive a boost (speed for example).

void Update () {
gameObject.transform.position += new Vector3(0.1f, 0.0f, 0.0f);
}

How should I increase the speed? Using if in void Update () {} ?

Like: if (smth have happend)
gameObject.transform.position += new Vector3(0.5f, 0.0f, 0.0f);

Thank you

Vector3 speed = new Vector3(0.1f, 0f, 0f);

void Update () {
   gameObject.transform.position += speed;
}

and then in response to the collision set speed to new Vector3(0.5f, 0f, 0f); for example.

You can change it back after a certain period as required.

Thanks a lot. Works find
Can you tell me how can I set a certain time for such boost?

Youre using rigidbody and changing transform.position at the same time? Doesn’t make sense, to change your object’s velocity use rigidbody.velocity or rigidbody.Addforce (for use case look for these methods in API docs).

@kir_e You should take a look at coroutines and/or Invoke() as a means of implementing a timer for the boost.

Also Roni92pl makes a good point, if you want your object to behave properly with other physics objects then you should probably use RigidBody.MovePosition() to move it, if you’d prefer not using forces.