Prevent actor bounce on collision
I'm new to UE4. Currently, I'm trying to make a simple breakout game. I created the paddle as an Actor in the game. The paddle is controlled by the left and right arrows. I'm doing most of the game logic and input handling in C++. The problem I currently have is when the paddle hits one of the side walls, the paddle seems to bounce back and continue moving in the direction it bounced even though I'm not holding down an arrow key.
The paddle has a cube component which simulates physics with a mass of 0. Simulation Generates Hit is checked since I want to be able to hit the ball and call custom code. The side walls also simulate physics and and have simulation generates hit checked.
The APaddle class has the following code:
When the paddle hits a wall and I release a key, the m_velocity is 0. I don't understand why the paddle continues to move. Any help is greatly appreciated. Thanks!
asked Jul 02 '18 at 04:25 PM in Using UE4
The first thing I would suggest is, since it is receiving input, to make your Paddle class inherit from Pawn instead of Actor. Pawns are Actors that are meant to be "possessed" and receive input from controllers (or KBM).
To fix your problem with input, though, I would suggest making your MoveRight input action an axis where your inputs to move left have a scale of negative one. Using an axis mapping over an action mapping will allow you to directly set your "m_velocity" X value to the input value as the callback is called even when the axis value is 0.
answered Jul 02 '18 at 07:47 PMDarkwindRichard (suspended)
Follow this question
Once you sign in you will be able to subscribe for any updates here