I am working on a simple platformer where I have added an elevator, or more specificly a platform that is moving up and down. The problem is that if the player pawn, a simple ball, is on the platform when it starts moving upwards the ball starts to bounce up and down higher and higher. I have tried to lower the retuition of both the ball and the platform to zero but it still bounces a little. What i want it to do is go upwards with the same speed as the plarform. What should I do to solve this? Thanks
Kinda of unclear until I get some screenshots but, some things that might not be suitable but tryable are while assuming you have physics enabled are increasing the mass of the ball. Which should be the solution inside character movement component.
Another thing which should not be a final solution but depends on your view is to add a box collision on the elevator so that when the player enters it his gravity scale increases and when he exits the scale returns back to normal.
seems like changing the mass of the ball didnt make any difference on the bounce. it feels like if the platform makes a great force on the ball pushing it in an upwards direction so that it moves even faster than the platform. Gonna need some help here.
I will try to recreate this and reach back to you till tommorow. Cheers.
Thanks very kind, thanks alot
Alright, I decided to do it right now so that I don’t forget.
What I did was use the rolling ball temple (assuming you did the same).
The problem is the ball itself and physics, now in a normal character actor we get the “character movement” component which helps in adjusting a lot of things like gravity, velocity and what not.
In this we don’t, it simply has a mesh which has physics enabled and some controls that are driven by variables.
So, manipulation of mass does not help us,
Now, in the default scenario, I created an elevator that moves with the help of a timeline (Assuming you would have also done the same thing). Here is the code.
When the timeline is set to its default of 5 seconds, everything works
fine-ish, it is just that the elevator moves slowly. The problem is when you make the elevator do a sudden movement. Because no matter what the elevator will move and the ball will follow physics.
So, the solution that I found was, to off-course make the ball stick to the ground, which is done by the almighty GRAVITY. But as we have no character movement component, we cannot change the gravity inside the BP (AS FAR AS I KNOW, WHICH IS NOT THAT MUCH).
What you need to do to try this out if you like is -
- Follow this tutorial to override the world default gravity - (Set it to a very high value like -1000). THIS WILL EFFECT every single physics object in the world.
- Now mass comes into the picture as when you now collide with other physics object, not much force will be applied to them. So to correct it you need to increase the mass of the ball.
So summarizing my 15 minutes of experimenting,
Two possible solutions -
- Either don’t make the elevator do a sudden movement.
- Follow the above three points.
You will see it all comes down to level design in a physics based game. You need to think a little like a physicist.
Thanks! this made it better. Too bad it didnt solve it completely, you still get a tiny bounce.
A simpler way to do it would be add an invisible, one way roof. That way the ball can drop on the platform if needed but cannot bounce