Moving my character on a circle (mobile)

Hey everyone,

Might be a simple question for many. But I was wondering how I could make my character move on a circle using a joystick (virtual joystick on mobile).

This means when I move my joystick the character moves along a 360 path.

I made a little illustration of how that could look.

Thanks in advance
ps: I am very new to unreal, so take it gently :wink:

hi,
just one more question, where should the character face ? because if the character will always look in center of the circle if will go in circles but with sidesteps :slight_smile:

cheers :vulcan_salute:

1 Like

If I’m understanding correctly, you can do this by changing the relative location of a component within your actor, and then rotate the actor itself.

Below is an example setup of what this means.




The yellow cube (Cube) is at 0,0,0. Rotating the actor will rotate it just as a it would alone.
The grey cube (Cube1) is at 400,0,0. Rotating the actor will rotate it in a circle orbiting 0,0,0. 0,0,0 is where the yellow cube is, so it’ll look like it’s orbiting the yellow cube in this example.

To rotate it as mentioned above, you use the set actor rotation node and change the Z (Yaw) value:
image
image

1 Like

That would be forward. So it means that we are looking at the back of the cube in this case.
The bottom of the cube should stick to the path. So when it is on the top of the circle it would be upside down.

I am trying to understand :slight_smile: (new to this)
So what you are saying is we can make a cube orbit around another cube. Like the moon orbits the earth? That seems reasonable to do. But then how would I control this value? Or add a controller (joystick) to it to change that orbit value? Thanks in advance for helping me out!

It’s not actually rotating around the other cube. It’s rotating around the location (0,0,0)- the location the other cube just so happens to be at (0,0,0). It’s like the moon orbiting a non-existent/infinitely-small earth.

To control it, you would do the following in your character blueprint.
Keep in mind that you’ll likely have to change stuff if you’re using a template (like the 1st person shooter and top-down templates) to get the rotation to work.


To change what input is being used, you can change the GamepadLeftThumbstickY-Axis event there to something else- it’s available for most keys. The Y axis should be left and right- contrary to every graph you’ve ever seen. Gamepad is a general term used to refer to all controllers.




Of course, this is only when you’re new. When you get more comfortable with the engine, use Unreal’s EnhancedInputActionMappings system. You’ll need to for keybinds.

2 Likes

hehe i made some too ^^
i used RotateVectorAroundAxis :slight_smile:

Axis => will be the axis of rotation, can be any in this case (0,0,1)
Offset => is just how far it should be away from the center or any other object if you add to it… in this case (0,-400,0)
MoveAngle => will be the speed of rotation (90 for the demo)
CurrentAngle => is the result, but you can make a default value to start at any point (360° input)
the optional is for facing in the direction of rotation… can be deleted

here what it does :slight_smile:

cheers :vulcan_salute:

1 Like

Woah you guys are amazing! I’ll try it out and see if I can replicate this for myself! Thank you so much!

1 Like