Create a rolling ball controller (top-down like "Waves")? Example included.

How would you go about creating a ball you could roll around with the WSAD keys similar to something like this in Blueprint:

I’d like to be able to to similar twin-stick aiming controls as well, but right now I’m focusing on the movement itself first. Thanks!

Depending on how you want your controls to work and how much physics you want - you could create a physics based sphere for the ball and apply forces to it bound to the WASD-keys. Or you could make sure the ball has a Movement-component and update it’s Velocity variable when using WASD.

I’ve been trying to do the physics based method, but I don’t know what I would use to apply the forces.

I’d also really like to know how to accomplish this. Getting hung up on how to apply a force to an object via inputs such as WASD or Joystick Axis.

Check out something like the third person template, but replace the ‘add movement input’ nodes with ‘add force’ nodes!

I really want to build a ‘physics ball’ template for next release :slight_smile:

Haven’t actually ran this BP but just as a mock up I think this is what you want.
Set up your input axis mappings like in the picture. The in your BP create 2 MakeVectors, one for horizontal movement and one for forward movement. Add these together and use it as your force. You’ll probably want to add a multiplier in there to get more control over the force amount.

Let me know if this works.

Here’s a level blueprint example I put together with torque instead of force, and using the tick event…although I think the above method’s input handling is more sensible :slight_smile:

veggiesaurus I got your method working, but only as a level blueprint. I can’t figure out how to apply this to a character, because I’m still confused on the actual character creation process. (As in having the ball as a player with a parented camera.) I’ve looked at all the documentation, the forums, and even the included top-down template and I’m still confused on how to do it.

Edit: Wow okay so it turns out I was just forgetting to override the gamemode so I could set the player class. Now I’m stuck on this stupid problem where I will rotate the camera in the player’s component view, yet it still faces flat in-game. Anyone know what’s causing that?

Edit 2: Oh okay, I missed the “Use Controller View Rotation.” Now I just need to figure out how to constrain the camera’s rotation so that it won’t be spinning around with the ball like it currently does.

So I made some progress on this tonight given the information here. I’m using Add Impulse instead of Force or Torque. What I want is for the ball to accelerate at a constant rate in any direction and cap the speed at a variable limit. I’m sure there’s an easier way to do this than what we’re trying to do here with the physics based approach… but such is learning the ins-and-outs of an engine as we try to clone a game.

How are you guys accessing the forces and torque nodes? Is it a specific class you are extending the blueprints from?

Try searching in the node menu on the right. Check my picture. Sometimes the rightclick context menu doesn’t give me what I’m looking for.

Yeah specifically you need to Uncheck ‘Context Sensitive’ if you want to search for a node through the right-click menu. Or optionally use the library browser to the bottom right of the Blueprint window.

Just un-check the “Context Sensitive” box and it will allow access to all the nodes.

Also does anyone know how to get a camera attached to the ball so it will follow, but not rotate WITH the ball? I’ve been trying to figure this out forever. Anything I try just results in the camera spinning all around the level.

Also, Impulse works a lot better, but it still feels off. Sometimes it’s not registering key presses and I have to press it again for it to go that direction as well, and we still need to figure out how to make it so that when there is no input, it will stop rolling instead of continue.

Edit: wheeeeeeeeeeeeeeeeee

So what I did to prevent the camera tumbling was I added in some dummy components to attach the spring-arm too and another component to serve as the “root” parent.

So more specifically: I have a camera that’s a child of a spring-arm that’s a child of an arrow with visibility set to none. The arrow and the ball are both children of a sphere, also with visibility set to none (really you can use whichever components you want, any primitive will do).

Every tick I move the arrow to the position of the ball. It’s a dirty work-around but for now it solves the problem.

Here’s a screenshot of my blueprint so far:

My setup works with both WASD and and Xbox 360 controller. Just as a note, for whatever reason the Axis is reversed on the controller… which is why I have the Stick X going into Y, etc.

What I’m trying to figure out now is how I can cap the speed so that it doesn’t just keep accelerating forever.

After that, I want to put together a better way to slow down to a stop. You’ll notice that in Waves the ball won’t immediately come to a stop, but neither does it’s momentum affect how quickly it comes to a stop. I don’t think he uses physics forces and the more I’m working with them to clone that control scheme, the less I like how complicated it is.

Like, even after I get both of those things done, I want to also be able to change direction without having to decelerate before accelerating again. If you move in the opposite direction currently, you have to first apply opposite force to dissipate your momentum to begin traveling in the opposite direction.

Nice setup so far. I got mine working similarly, but I can’t get the camera following still, it just jumps around randomly every couple seconds. Can I see your component setup?

Edit: Mine seems to be moving the same distance the ball moves, but in the opposite direction, and only when I let go of the key. Weird.

Edit 2: Forgot to link the false branch to move component, still can’t find why it’s moving the opposite direction.

Sure here’s my components:

The important thing to remember here is how this is all parented, because it’s the parenting that’s causing the tumbling issues.

So I have it like this:

[Root] Container (Sphere shape with no visibility)
    Ball (My mesh I'm using the for the ball you move around)
    Camera_Target (Arrow primitive with no visibility)

Make sure that the Ball and the Camera Target are both children under the same parent. That’s an easy part to mess up because the sorting for that kind of thing can be tricky.

After that, you basically want to reference both components, grab the world location of the Ball, then use that vector to move the Camera Target to. You do this once per tick, and it’s probably safer to make sure that’s the last thing in your scrupt that happens. You should be able to figure it out with the two screenshots I’ve provided.

If you ‘drag and release’ off a StaticMeshComponent pin it should offer all the various physics functions for applying forces. Are you not seeing that?


You can look at the side scroller template for an example of this. Select the SpringArmComponent, and click on where it says Rotation to toggle it to Absolute Rotation. This means the rotation is treated relative to the world instead of of relative to its parent component.


I remember that exact same “feature” in my UDK rolling ball test :smiley: Combine that with Occulus support —> instant sickness

Wow, all this time and that’s all I had to do, haha. Thanks!

So now we just gotta figure out how to cap the speed, and how to slow the ball to a stop when no input is being entered.

Edit: Well I guess we know how to cap it with linear velocity, but currently that just make it stop dead in is tracks when you let go of the controls.