World rotation works... and then it doesn't.

So I have an NPC that turns to face you when you talk to them, and that works all fine. But when I want to return the character to their original rotation SetWorldRoation does nothing.

  • According to the breakpoints and
    print strings the piece of code that
    should rotate the NPC back is being
    run when I want it to (when dialogue
    with NPC is closed)
  • When I run talk to the NPC again
    after they don’t rotate back, they
    still rotate to face the character.
  • The code that the rotate to face
    player and rotating back are running
    are practically identical.
  • Even when I just set a random set of
    numbers in the new rotation section
    of SetWorldRotation, nothing happens.
  • I run the code after setting an
    AIMoveTo to nothing. But this doesn’t
    change anything when removed.
  • The Actor is of character type

^^The code in question that doesn’t work.^^

^^and the code that does work.^^

I really have no idea whats causing this… Does anyone have an idea?

Thanks,

you dont have anything plugged into delta time on the RInterpTo node… drag that out and type get world delta seconds

Thanks for the reply, unfortunately this didn’t do anything though, seems also that set location isn’t working either

Could you do it like this? First save your values and after that just reverse depending on your stored values?

341738-reverse-rotation.jpg

That is just my shoddy naming conventions I think. In this case, CurrentRotation refers to the rotation of the character before being rotated to face the player. It gets the variable when the code in the green gets first run when the player talks to the NPC. So by setting the CurrentRotation again in the update in the timeline, I’m trying to set it for future use.

But right now I’m not actually using the rotation variables. I made them to try diagnose the problem or just to make the rotator actually do something by setting it to a variable. This didn’t work unfortunately. Turns out even putting a value directly into the SetWorldRotation won’t do anything either.

Also recently discovered that by manually running the event in the editor it will rotate the character, but it will only do it once. Its very peculiar.

Thank you! Yes this code does indeed work as intended when manually called in editor, but not when run on the exit dialogue event. It could possibly be because I am running the code on the parent of the child actor that this is meant to be working on, but the original rotation works…

Sorry, I edited my last reply, but luckily you saw it. How do you call your exit dialogue event?

Well when the dialogue is closed, it runs a BTTask Blueprint base class which tells the dialogue box to disappear and for the first person player to not move. It then Gets all actors of class of the NPC parent class and calls the return event. According to the breakpoints it does get run, but it runs through the SetWorldRotation like it isn’t there.

For your Return: Shouldn’t you switch CurrentRotation and NewWorldRotation at the RInterp?

Nope it seems to rotate as I want it to this way, at least when run from the editor.