Make A Ball Roll Forward Regardless of Surface Normal?

I’m trying to make a rolling ball game. I need the ball to roll towards the camera forward vector on any surface normal. Can anyone help me figure out the script?

Do you need any kind of true physics? A kinematic alternative would be to use a normal character, configure it to being able to “walk” on steep slopes, and animate the rolling based on the change in location each frame.

Unfortunately, the ball’s movement uses true physics and has to stay that way :frowning:

unfortunately “true physics” and “roll towards the camera forward vector on any surface normal” are mutually exclusive conditions.

As HavocX suggested, in order to roll towards the camera forward vector at a uniform speed and on any surface normal you will probably need to implement a kinematic alternative.

As a potential experimental alternative, you could experiment with constantly applying a force to the ball towards the camera, and increase/decrease the force applied to compensate for steeper slopes.

For example, continually increase the force until there is positive velocity toward the camera.

However, this will result in non-uniform acceleration towards the camera and may be difficult to control e.g. some balls will be faster than others depending on slope traversed.

I have not tried this myself but might be worth testing,

under your objects Physics tab you might have an ‘constraint’ option. Try changing the mode to ‘Custom Plane’ and feed in some dynamically updated numbers that represents the plane cutting through your view forward. If you’re lucky maybe it’ll make a sort of ‘2D physics’ constrained to that plane?

EDIT: Or could you just work out the world vector pointing sideways from your camera view and then use that to multiply objects’ velocities to zero in that dimension?

EDIT2: Reading your question more carefully, another hacky way might be to take the camera forward / ball rolling direction and sample the ground normal a bunch of times along that direction and then average those normals to give you a sort of ‘average slope’. You could then maybe disable Unreals own gravity and replace with a force angled towards your new average normal?

You can also try the Custom Gravity Plugin found here -

It would basically allow your ball to “stick” to any surface by changing the gravity based on the surface normal.

hi! I did (and am still doing) a tutorial serie on a rolling ball mini game. I’m sure you can find these videos to be very informative :slight_smile: