Announcement

Collapse
No announcement yet.

Save initial rotation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Save initial rotation?

    Hiya there,

    Sort of a noob question, hope you guys can bear with it... :P

    I have a BP which contains a Sphere (static mesh), along with a Rotating Movement Component.
    This is my game field, and I wanted the user to be able to navigate around it (WASD keys). So, the architecture goes like this:
    whenever the user presses one of the above navigation keys, it only updates the values of several boolean variables: shouldNavForward, shouldNavLeft etc. (for all possible directions).
    At each Tick event, I call a function which checks the values of said boolean variables, and by them determines the action to follow (navForward, navLeft etc.).
    Each of the final functions adds the appropriate RotationRate to the BP's Rotating Movement Component (Yaw for moving left/right, Pitch for moving forward/backwards).
    On top of that - this BP has a SpringArm with an attached Camera component; whenever the user scrolls up/down, the length of the SpringArm is changed accordingly, zooming the view in and out.
    All of the above seems to work fine.
    I want to implement another functionality, which saves the initial position of the Sphere, and enables the user to return to that exact position at the hit of a button.
    So, I tried several approaches for this; last thing I tried was to create two new variables (one for pitch, and another for yaw), which are updated whenever the player moves the sphere (basically adding/subtracting the movement rate to its matching variable). Then, when I try resetting the Sphere's position - another function (resetNav) adds the saved values to the Rotating Movement Component's RotationRate. I tried that with both adding and subtracting, getting virtually the exact same result (how is that even possible?).
    I also tried saving the Sphere's relativeRotation at BeginPlay (which obviously didn't work, since its initial relativeRotation is 0), or its worldRotation, and then set it to the sphere's mesh (via set world rotation). That also didn't work (caused my sphere's axis to change somehow).
    I always reset the Camera component's SpringArm's length to its max possible value before trying to set the sphere's new rotation (which is actually supposed to be its initial rotation), but nothing afterwards seems to work right.

    SO - given the architecture above, how the hell would you 'save' a mesh's initial rotation, and how would you recover it later on?
    What am I doing wrong?

    Thanks in advance & good night!

    #2
    Really?
    I thought that was something really basic!

    Well, bumping once, I'll give it another shot.

    Comment

    Working...
    X