Download

Character Rotation Resets to Default

I have a system where right now when the player attacks, they can switch where the attack is headed in-between attacks (sort of like action games like DMC or Bayonetta), this is triggered by an animation notification that switches a boolean on, there’s a function that’s on Event Tick that’s always checking for when this bool is on, and when so, sets the desired character rotation, the problem is that after it is set, after a second the character’s rotation is reset to its default station (90 degrees on yaw at the moment), I’ve heard it might be because it’s on tick but I am not sure how I can fix this problem, below are some screenshots and a small clip showing what’s happening, I appreciate any help that you can give!

Video - Rotation Reset - YouTube

Hey,
I do not know why the solution does not work, but I have a picture attached as I do the rotation in my project.

I call the part directly after starting the montage. The float value at the top left is the “montage” length, I divide it by 4 so that the attack can only be directed in the first 1/4 of the attack.
The timeline should be at least as long as the longest montage you want to play.

So your rotation doesn’t reset after a bit? I believe my issue might be related to it being Tick, so I’ll need to try doing it either on the anim bp or find a way to not have it on tick (besides the fact of it eventually being something that taxes the system while it isn’t needed).

I would replace the target rotation calculation. Your calculation leads to a target rotation of [0|0|0], because if you do not move the floats are 0 and the result is an added vector of [0|0|0].

You should check with print string if the rotation is set wrong.

The target rotation should be fine cause it does rotate how I want it, it’s just that after half a second (so after everything ends) it rotates back to the default position [0,0,-90].

You should avoid tick if possible, but in your case I think it’s recommended.

However, I think your problem is with Get Actor Rotation in tick which needs to take rotation before you start animation (as start point, not update every time).
This applies also if you do this with timeline. Take Actor Rotation before update, not during update rotation,

I see, I’m guessing that’s what causing the issue, cause for a short bit after the rotation is done it still has time to get the rotation again and it resets, I’ll try that out ASAP and tell you how it worked out!

Unfortunately taking the rotation before the animation makes it so that the character barely rotates, which makes it that the next time I rotate it goes back to the previous rotation only with a bit more rotation added to it.

I would give my solution, which I posted earlier, a try.
Here is a preview of what the solution looks like ingame.
You can see that the character does not rotate back.

It won’t work in tick, but in Timeline or Function with timer.

So I did your exact answer (except I connect what’s happening between the Anim BP and the Character BP through an event call cause my montages are play on the Anim BP) but right now what happens is that whenever I attack the character just shifts to the default rotation (so -90 degrees yaw) and always goes for that, independently where I’m trying to aim it for.

Here’s some screenshots of it.

With timeline it works when turning but again when releasing the attack button it goes back to the default rotation.

I do not do anything in animation BP, here is where i call it. (Ignore the Notifications)

Does your character follow controller rotation? Maybe you should use Player Controller -> Set Control Rotation instead of Set Actor Rotation.
Because in your case character will rotate but will reset rotation to your controller rotation after animation.

Here’s what happens when switching the Set Actor Rotation for Set Control Rotation: https://www.youtube.com/watch?v=yXKIBSz5xHs&feature=youtu.be

What do you want to achieve? I mean you need a direction or a target to rotate a character in that direction during attacks (as in mentioned games like DMC).
You can always use Find Look At Rotation and rotate character to target. Something like this:


Also, in Character Movement you probably need to check Orient Rotation to Movement.

And probably you need to uncheck Use Controller Rotation Yaw for your actor (if it’s checked it will reset rotation to Controller instead of actor rotation).
123.jpg

Like I said in the first post yeah it’s something akin to DMC. I’ve had both of those options checked and unchecked since the beginning too (since even the ‘non-working’ version needs those to work).

May I ask what does your GET come from? I’m willing to try that version you’re showing me, going by the logic of the nodes sequences I think that might be it!

Sure. GET is from the target actor or enemy that your character will be focused. I usually get nearest target actor. To achieve this you can use various methods.

  1. Get **all actors of class, **find nearest actor as target.
  2. Or maybe better solution is to create collision sphere on your character with specific radius and than Get all overlapped actors inside that sphere around character. You can choose target in different ways (not sure how they did it in DMC because I never played it): choose nearest target or choose target that you are looking at or maybe random target…

Hm, what if I don’t want to get an enemy around me? So for example I can just attack around without focusing on an enemy, say the enemy is in front of me but I can just attack to the right and left sides, what would be the target on ‘Find Look at Rotation’?

Is there any conditions for these attacks (to the right and left)? Or random?
This works for me:


Character will rotate for 90 degrees on the left side.