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.
I’m using set relative rotation - people can have exact dynamic control over the frame by frame of the rotation.
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.
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
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?
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.
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
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 (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.
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.
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.