How to correctly rotate pawn to its move direction on a sphere platform?

I have a pawn that moves on a sphere surface to clicked the clicked location. I want to rotate it to its move direction and also parallel to the sphere face. I did it. However, that turns opposite direction of its move direction. Most probably I am missing something simple. Do you have any solutions for this issue ?


You can see the video here:
FlyingUnit - rotation problem - YouTube

Here is the SS of nodes that do rotation:

The rotation issue was the problem caused by lack of line references. I tried to do it with only two lines. Second big problem was I had to connect unit location to Z and target location to X not the thing I posted on image. After that removed all of these about rotation and put them to BehaviourTree’s execution.

At my first attempt I did tihs: Flying Unit - move points - rotation corrected - YouTube - in this method the problem was; Lines’ amout was fixed and distance between them not constant.

At my second attempt I did that: Flying Unit with fixed move line length - YouTube - here I made a c++ node that calculates how many constant size lines would be in a line and got their percentage based on full size.

TArray<float> UGalaxyBlueprintFunctionLibrary::LineBuildPrecentage(float InLineLength, float InSubLineLength) {
	int wholeInDistance = InLineLength / InSubLineLength;
	int maxIndex = wholeInDistance;
	TArray<float> LinesPercents;
	for (int i =  (maxIndex-1); i >=0; i--)
		float p = (((InSubLineLength * i) * 100) / InLineLength) / 100;
		float p_rnd = ((round(p * 100)) / 100);
		if (p_rnd == 9.999f || p_rnd == 9.99f || p_rnd == 9.96f) { p_rnd = 1.0f; }
	return LinesPercents;

after I called it in bp and set sublineLength as example 5. Now I get only needed lines with fixed distance.

I you have any advices please let me know.

Try separating the movement ( which has to follow the sphere ), and the rotation of the pawn.

The movement has to be according to some math, but the rotation of the pawn and just be local rotation. You can use ‘look at rotaton’ I’m assuming.

I made something like this : Flying Unit - move points - rotation corrected - YouTube

1 Like

So it works now for you?

yes, but when distance is very close I still have more move points. I think I should set a min distance for those points to add move task.

1 Like