Hello folks. As the title suggests, I am attempting to do something that seems very simple in concept, but has been giving me a hell of a time. I have to admit some incompetence here- my approaches may have veered way in the wrong direction. Please feel free to correct me.
**
Objective: Using the X, Y and Z keys as inputs I want to rotate an actor around it’s X, Y and Z axis respectively. They should rotate 90 degrees each key press. **
That’s it. I’d like to be able to figure out how to do this either using local rotation of the actor, or world axis, as I am not sure which will feel right for my purposes.
I’m a novice with blueprints, but my first attempt to make this work looked like this (the Y and Z axis have identical node networks, except referencing the proper axis):
The problem with this approach was I kept running into gimbal lock, or the axis just would rotate in a direction you wouldn’t expect them too. It was very incomprehensible as a game mechanic that the player needs to be able to control.
Assumption: SetActorRelativeRotation was the wrong node to use for this situation.
Attempt #2: I decided to replace the rotation node with an AddActorLocalRotation
I couldn’t get the timeline curve to work, so I temporarily removed the LERP while I just try to get the rotation to work. This is my first time working with Delta Time, but I tried to read up as much as I could find.
This blueprint no longer gave me gimbal lock issues, and it is much easier to control which direction you intend to rotate the actor. However, now my problem is that the actor doesn’t rotate precisely 90 degrees, but rather some messy amount like 90.345614. As I repeat the rotations, the discrepancy increases. I assume this is because the math that determines the rotation delta is based off of my framerate, which is not constant? (After I solve this issue, I would also like to reconnect the timeline for a smoother rotation, if possible).
So are either of my approaches close to being correct? Or do I need to try some entirely new method? (Hopefully you didn’t notice I spelled 'Increment" incorrectly in my variables =P)