How to odrer array clockwise?

Hi anybody knows how to order an array clockwise from given vectors ??? Help will be appreciated.

You mean you want sort the array AND put it in a circle?

I Want to sort it clockwise like on image. But the locations should stay like they were.

Can it have any number of slots?

Are those numbered objects actors that you want to arrange in a circle? In that case I would store references to them in a map variable where the key is an integer and the value is a reference to the actor.

Then, you can use a for loop (not a for each), to find each key and get the reference to each actor. Since you’re using a for loop this will mean that it doesn’t matter what order the map is in; you’ll always find the keys and get the values in the right order.

If there are gaps in the numeric sequence, that’s okay, because the find node will just return false and the for loop will go to the next index. In this case though, you’d need the end of the for loop to be the highest key value, not the length of the array, but since you created the map you must know what that is anyway.

On each loop it’s a fairly simple bit of maths to calculate the locations based on the length of the array variable and dividing the circumference of the circle by that number.

I’ve recently done something very similar. However, I did it in C++; I don’t think it’s easily possible in blueprints, since they do not allow sorting arrays automatically, like C++ does. Maybe you can create your own sorting function in BPs.

Anyway, the idea is to sort the the vectors based on their angle to another arbitrary vector. Like make a rotator from a vector that goes straight left, and calculate Delta Rotation against rotators made of all the other vectors.

Or you can use Dot Product, but in your case you’ll need to compare against two vectors, like Up Vector and Right Vector.

Ah, I do believe I misunderstood the question.

This is possibly a silly idea, but you could sweep a line trace from the centre out in a circle and every time it hits an actor of the right class you add it to the array.

Or move an object along the circle and use the overlap event.

I think it’s just forward vector * distance, plugged into a rotate vector node…

Yes it can be it but I want to do it in blueprint. Thanks for hint

Then how do you test that an actor is at the location given by the calculation?

I think you’re putting them there, no?

I’ve no idea. The question isn’t very clear.

Sorry, I don’t think we’re going to get very far here. Do you want to sort an array, or put the elements of an array around a clock?