Understanding Aerial rotations

Hey,

I have a little aerobatic pawn. He’s a chill guy but No so good on the Aerial front.

I can understand axes when it’s either Z or Y. But as soon as you put them together. Its get a little strange.

So here’s my thought process. Ive got an input on the Y axis, It makes the guy do a backflip

I can plug the same input in the Z axis, and do a flat 360.

perfect so put them together and you get a backflip 360?

Well… not quite.
So how do we handle aerial rotations?

Current plan: Do the maths to rotate it 90 degrees at a time and then using a branch each time to course correct the rotation. Apparently something called gimbel lock exists and potentially is the cause of the issues.

Some extras that might help.

  1. I’m using set relative rotation - people can have exact dynamic control over the frame by frame of the rotation.
  2. I tried timelines, but they just didn’t have the “scrub” ability to really stop and rotate back and forth to really see the rotation.
  3. I also tried add rotation but it got crazy.

I’ve had a thought…

Could you just aim your character at say a floating sphere off-screen that essentially moves through space, so essentially the pawn just faces the sphere (off screen) the whole time.

I can then add rotation after that to hit the correct position on each 90 degree hit?

This feels like one of those using a nuke to control an ant hill type situations xD

Ok this works.


Essentially an orbiting sphere the player’s pawn can look at. It’s not overly tested yet, however.

If Anyone is copying in the future. Im changing the orbit speed float value and radius float.

  • Orbit speed is exactly what it says and radius makes the sphere do a bigger or smaller circle.

Although Im now In a world of hurt trying to create an orbiting sphere based on a mouse input. Oof

Few weeks ago there was topic about almost same problem:

I hope it helps.

2 Likes

Interesting it seems even with creating an orbital tool for viewing it still creates the gimbel lock issue.

Hmm tough cookie. Thank you for the link. Ive ran out of time but Ill read the whole thing asap.

For gimbal lock best are “quaternations”.

1 Like

Yeah, everything keeps pointing this way, but it requires going outside of nodes which Im not crazy confident with.

Reckon you could use simulated physics to deal with it? have the game engine figure out the rotation instead of me. But have a really specific thrown rotation to reproduce the spin?

There is HAX way of doing it:

  • assuming that ALL movement is at tiny distances (not too fast and done on event tick), not too fast is below 250m/second range, so comparable to character pawn running speed
  • You have center of sphere, and location of pawn
  • From center to location you can create vector, which would be also Normal vector (just normalize it)
  • then create flat and perpendicular plane (to that vector/normal) going trough pawn location
  • now you have plane of motion, so move your pawn on that place
  • after moving ADJUST location of pawn to be exactly diameter of sphere

Yes some vector math is needed, but no gimbal lock and no POLE singularity.

TL/DR:

  • on sphere find plane your pawn is moving on, move a tiny bit, adjust radius/disstance from center. Repeat on next tick.

Interesting, yeah it is currently controlled by enhanced inputs from the mouse to create spin like a soft flick and an event tick to keep rotation going until the input changes.

I tried to write this out in nodes, got a little help from chatgpt to try and simplify it, but I’m lost towards the end, adjusting for the diameter of the sphere.

Would you have visual?


This is kinda where I got too but wasnt sure what to place.

On a side note, mini rant on unreal, I’m nearly 2 weeks into this problem, and ever frustrated how difficult it is to just rotate a pawn on 3 axes. What a wild oversight to not include quarts nodes or any way to deal with gimbal lock or any alternatives.

I just want to be able to dynamically spin my lil guy :smiling_face_with_tear:

This code (done in construction script) will draw plane perpendicular (aligned with sphere surface):

I am stuck a bit, because they introduced that new plane structure, not sure how to reorient orbiting actor/component using data from that struct.

And you need to reorient your pawn so it can move using (its own) forward vector and right vector

What about something totally rogue like manually adjusting constantly every single 90 degrees readjust?

I tried something like this

or

This is the same, just using rotators instead.

But Manually adjusting for the wrap is outside my understanding. I did get into a convo the other week about this, I’ll give it another read.

The rotation is only affected by a singular float value as well. so Its quite basic.

For this problem, do not think in category of rotations. Think about vectors.

You need to find plane, then find forward and right vectors of your pawn projected on that new plane.

From that you find new rotation.

Then you can rotate pawn, adjust new location back to sphere, and move pawn.

I got to about here and got lost again towards the end. :smiling_face_with_tear:

What about something like this?


This isnt finished but It gives a jist.

alternatively Is there anyway to just fake rotation?

Its just a pawn on a black screen to show how rotation works for aerials. Is there some kind of fake out that gives the impression of rotation without rotation.

Like for example making the camera and the background spin around the pawn instead?

Im thinking maybe just adjust manually on the wrapping every single time. And totally cut out any type of real time rotations.

Also huge alternatives,

what about the rotator to quarts and quarts to rotator nodes?

OK, so I’ve been digging around a lot more to figure out how to rotate pawns correctly in game. (This is just a bit of an update for me to keep track of where I am as I bounce around alot with work)

The Euler angles and gimbal lock cause massive issues.

However, you could use impulse/angular velocity/torque to rotate with instead and let unreal figure it out with simulated physics.
This causes another issue, axes that collide incorrectly :smiling_face_with_tear: (why is this so difficult for such a basic core function)

So chatgpt has mentioned the way to get around this is to use “Use Quaternions for Combined Rotations”

Now we can’t really use quaternions due to unreals strange decision to limit access to them in blueprints, But we could maybe use either the “quats to rotator” or “rotator to quat” nodes to figure something out.

This however gets another roadblock, that you can’t directly use these nodes with angularvelocity/torque/impulse due to them using a vector. :smiling_face_with_tear:

So Currently I’m seeing 2 options.

  • Figure out rotations with vectors to create the right spin. eg. a 360 flip (360 on 2 axes at the same time)
  • Learn quaternion maths to figure out the right equation needed to send the pawn on the correct path through.

All so I can just…spin a pawn.

I see you getting into it . :smiley:

So it is time for just an idea:

  • make code plugin (C++), make it function plugin
  • then see this function here:
	UFUNCTION(BlueprintCallable, Category = "Transforms & Paths", meta = (ToolTip = "Rotates set of transform points around location"))
	static TArray<FVector> RotatePointsAroundOrigin(TArray<FVector> Points, FVector LocationA, FVector LocationB, float RollValue)
	{
		// Calculate the rotation quaternion
		FVector Direction = LocationB - LocationA;
		Direction.Normalize();
		FRotator Rotator = FRotationMatrix::MakeFromX(Direction).Rotator();
		Rotator.Roll += RollValue;
		FQuat QuatRotator = Rotator.Quaternion();

		// Rotate each point in the array
		TArray<FVector> RotatedPoints;
		for (const FVector& Point : Points)
		{
			FVector RotatedPoint = QuatRotator.RotateVector(Point);
			RotatedPoints.Add(RotatedPoint);
		}

		return RotatedPoints;
	}

Yes it is not what you need (as it rotates array of points, and they are not on sphere), however since you are using chat GPT, ask it to rotate single point around some location, using quats.

Then you can test and compile your tiny plugin C++ and keep main project blueprint only.