I have a falling object colliding with a “Power Cube”. This cube needs to get the velocity of the other rigidbody on collision and change the velocity of that object directly to a defined speed in a variable boostSpeed, while still keeping the same bounce direction as how a rigidbody would handle this.
I came up with this code but its not working correctly for me:
public class PowerCube : MonoBehaviour {
public float boostSpeed;
void OnCollisionEnter(Collision other) {
// Power Cube actions
other.rigidbody.velocity = other.rigidbody.velocity * boostSpeed;
}
}
This will increase the velocity but based on the current velocity of the object. I want all objects that collide with the power cube have the same velocity speed after they collide, but still in the direction how a normal rigidbody would respond. How can I do this?