- Home /
reversing current velocity of 2D rigidbody with button press
I have a 2D 'player' ball that is constantly bouncing back and forth between two platforms. How would i go about changing that balls velocity to the opposite direction on Key press.
Here's an illustrated representation: http://i.imgur.com/KZTBswD.png?1
The Black arrow represents the direction the player is going in, the Red arrow represents the direction the player would go once the Key is pressed.
so, how would i go about making a script that would inverse the current velocity of that ball? Just in general, if the ball is heading down how would i make its so that i press a key to reverse it to go up, and if its going up how can i make it so that a key reverses it and makes it go down. once again this is in a 2D work space.
Thanks all~! any help is very much appreciated, sorry if my explanation sounds confusing.