- Home /
velocity bounce
Hi i am having trouble making an object bounce off a wall. the object is attached to a hinge joint that is a a few meters to the right of the object. i am adding velocity locally downward to the object. it currently bounces if i have this:
void OnCollisionEnter(){
rigidbody.velocity = transform.up * Input.GetAxis("Horizontal") *30;
}
but i want it to bounce at the same speed as it hit the wall, eg if its going in fast, bounce off fast. i tried this:
void OnCollisionEnter(){
rigidbody.velocity = transform.up * Input.GetAxis("Horizontal") * rigidbody.velocity.magnitude;
}
but i think that the speed of the object is already 0 when it makes this call because it doesnt do anything. what should i put?
sorry it does work, i just found out that i had my drag increasing on collision enter. oops
i lie again, it doesnt work, but adding a bounce material sort of does it.
Your answer
Follow this Question
Related Questions
ball breaks through walls 1 Answer
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
rigidbody.velocity.normalized application 1 Answer
Velocity for movement 0 Answers
Why is velocity checking intensive? 0 Answers