Rotating object around an object. Please help!

Hello! I have been struggling with this too long now. I found a similar problem and Jonathan answered it by this:

There’s a ‘Rotate Vector Around Axis’ function that might help you out here. It’s under Math → Vector, and it allows you to input a vector, an angle (in degrees), and the axis around which the vector is being rotated. So, if you want to find out the X and Y coordinates of a point 45 degrees around the circle with radius 10, you would start off with the ‘In Vect’ X: 10, Y: 0, Z: 0, the ‘Angle Deg’ of 45, and the ‘Axis’ X: 0, Y: 0, Z: 1 (assuming the circle is on the ground).

I have tried to do that but i cant fiqure out how to use it in my project. I give you a couple screenshow. First is the picture what i am trying to do. So the object woudl rotate around the player all times…

And this is my blueprint. I bet this is all wrong, i have tried many different scenario, but main problem is that i dont actually know what those inputs mean so please, could somebody solve this for me? And if possible explain what is happening. I really struggle to undestrand different mechanisms.

This is other method what i tried… No luck

Last night I saw another question from you about your little box flipping around backwards in the rotation, and that made me think you’re probably thinking you’re on a different coordinate system than you actually are. I could be wrong, but if you’re thinking X goes to the right, Y goes up and Z comes out of the screen towards your face (like it would in, say, AutoCAD) then the code you wrote and the problems you’ve been having make sense.

I’d think in the game you’re making, X is to the right and Z is up (allowing gravity to work) … with Y going into the screen. When you rotate the box around the Z-axis (a line coming up out of your guys head), then that box would hula hoop around his waist causing it to appear backwards when behind him, right. I’m not 100% because I haven’t played around with Paper2D at all, but getting back to this particular question…

First thing is, you aren’t using the Delta Seconds from the Tick block to actually create any rotation. (And therefore, why even Tick this?) You’re going to want to create two float variables. One that stores the Current Rotation each frame as it spins around your guy, and another to add a small amount to that in each tick. Delta Seconds is going to give you a tiny value (depending upon your frame rate). You might want the box to spin faster or slower than this raw input, so the other float should be a Rotation Speed you multiply in to give you some speed control. Add this onto the current value of Current Rotation and resave the variable before doing anything else (per below).

http://s12.postimg.org/qav64v0st/blueprint.jpg

OK - now you can use this value to find the location to move the box to. I’d start by finding the location of your character sprite / dude. This will give you the center point of the circle. To this, you want to add a point on that circle using the Rotate Vector Around Axis like Jonathan mentioned.

  • In Vect: This is used to set the radius of the circle… In your case, the circle’s radius is 100 units.
  • Angle Degrees: This is used to say how far around the circle the box is right now… Use the value of Current Rotation in here as shown.
  • Axis: This is used to say what axis to spin around. Again, I’m gonna assume this works spinning around the Y axis instead of the Z, so I used [0,1,0] here instead of [0,0,1].
  • Output pin: This is going to be the x,y,z coordinates where the box should be drawn.

Note: I’ve shown this blueprint script as though the box and the guy are two completely different actors. If the box is some sort of component of the guy, you may need to alter the code a little bit. Another problem I see is that you’re getting locations in relative space but trying to set them back in world space. These will probably need to match up - for example, I get and set locations in world space in the example above. Hope this gets you going!

This helped me out. Was trying to work out how to rotate an object around a pivot point like this for a while. Thanks!