Trouble orbitting using RotatingMovement component

Hi

I’m really new to UE, so forgive the simple question. (I’m working in ue4.26 FPS template.)

I have an NPC drone that I want to home in on the player character than then, when they get withing a certain distance, begin to orbit around the character, staying with them as they move.

My idea is to use the RotatingMovement component, and adjust the ‘Pivot Translation’ variable to follow the the player (called ‘The-Target’), as per this blueprint which is attached to the drone. I’m running this on tick, so it keeps track of the target. (I have also include a Draw Debug Line to see what is going on.)

What tends to happen is that is moves in a strange circular path, starting at a point somewhere beyond the character. It does sometimes orbit but mostly it is just weird…

I would be hugely grateful for any hints about what I’m doing wrong, or better methods to acheive the same outcome. I have to say I find the ue blueprint documentation somewhat ‘sparse’…

Cheers Peter

Way easier:

Add one or multiple SpringArms to your Actor, that your Drones get attached to.
Switch off the “Do Collision Test”.

You can simply adjust the SpringArm Length and let it rotate.

That’s interesting.

I thought the spring arm was just for cameras…

I’m not sure how I would attach and detach it at runtime. There are a variable number of drones that are spawned at random intervals and they move in and out of the orbit distance and go back to homing…

thanks
Peter

You could use a springarm for rotation, it works - you’d need to add a component per drone. But you can omit it, and you can even skip the attachment if you’re willing to math it out a wee bit.

  • this script goes into the orbiter, it will revolve around the actor it overlapped:

Since we’re not attaching anything, there’s no need to detach. Closing the gate would leave the actor be and you can carry on running some other (homing?) logic instead.

Are those drones visual only or you plan them to be part of gameplay later?

Because if you want them to be gameplay you should code them as separate pawn/actors with AI. (done in blueprints, not blackboard) since they are only 4.