Sidescrolling Character Rotation Problem

So, I’ve started with the sidescrolling template, and it works fine. I want to introduce a character rotation mechanic based on Mouse Position. It works fine with everything being idle and no movement input. However, upon an input that is along the same direction as the player direction (Negative for left facing, positive for right facing), the player rotates the opposite way, but moves in the correct direction. I’ve posted my blueprint below as well. Please let me knowif you have any ideas, thanks!

I’ve delved into this a little further and it seems like at a certain speed this behavior takes over. Once the character reaches 301 velocity in the y direction, he switches around. If I keep his max walk speed below 300 or at it, it works fine. Any ideas why this is happening?

Hi ridley075,

In the above segment, you have it set up that if the players mouse is at a negative value, set the player rotation at 180. Set this to -180 and see if that places you at the correct orientation.

No, that didn’t work. -180 and 180 are basically the same thing when you’re talking about a circular turn of max 360 degrees. A negative value should only change the direction you turn (ie right or left) when making the 180 turn. At the end, the result is the same. I tried it however and didn’t seem to do anything.

I’m pretty sure it has something to do with the character movement component. Does anyone know of a setting that will toggle this behavior maybe?

Also just to be clear, I started with the blueprint sidescrolling template, and only changed the OrientRotationtoMovement setting to be off on the character, then rotated the mesh -90 degrees to face in the right direction when starting off.

Also, posted a video showing the problem. link here

I know this is for Paper2D, but this may help.

Basically it gets the character’s current axis value and it will turn in the correct direction by setting the rotation at either 0 or 180. I hope this helps!

Hi ridley075,

I played with this a bit more. How is your movement set up? I looked at your video and got similar results, but I believe this is due to the way in which the sidescroller project handles movement input as you stated. I will keep playing with it and see if I can come up with a viable alternative movement method.

This is what I have on my end, which seems to work OK, but is certainly not ideal. Note: the 90, -90 is because my pawn seems stuck on facing forward initially, which I am currently looking into. Do you want to be able to rotate with the mouse while moving? What you might be able to do is set up two branches. If “A” is pressed, set a bool to true, if that bool is true and you move the mouse, set the rotation to X (left) or Y (right), if D is pressed, set the rotation to X (left), Y (Right). This seems a bit convoluted but it might help to resolve the issue where the movement rotation is affecting the mouse rotation.

This didn’t seem to work, but thanks for trying! Also, I couldn’t access an update animation function, is that a custom one you’ve written? That might be the issue

My movement is set up in the image above. It’s the same as the template, except changed the OrientRotationToMovement variable on the character component to false. Basically just takes the scale value of the move right input and uses that in the Add Movement Input, with a negative directional value in the y direction. Again, same as the template.

Your problem might have something to do with thisanswers.unrealengine.com/questions/89839/pitchrollyaw-and-paper2d-question.html
cheers!

Update Animation is a PaperCharacter node. You shouldn’t need it. You basically need to find what your axis value is when you’re facing left and when you’re facing right. Then do branches to set your relative rotation (I believe it’s a Set Actor Rotation or something along those terms) to either 0 or 180.

Ok, finally figured it out. Turns out, the function Convert Mouse Location to World Space takes too long to complete, so when the player moves at a speed greater than about 300, it can’t run the function faster than the player movement, so it thinks the mouse position is essentially lagging behind the player. That’s why walking backwards works just fine, but walking forwards rotates the player the opposite way. So, instead what I did was compare mouse position on screen to the middle of the viewport, and so it works perfect now! Lol. Here’s an image of the working code now. Thank you very much for all the help everybody! It should have been pretty obvious when it only occurred at certain speeds. Oh well! Appreciate the support!

That is impressive work ridley075! I can see this working for a lot of different 2D games.

The issue as i had same as well when you set the axis values in BLUEPRINTS for movement Input you would think to set 1.0 for right and -1.0 for left… same thing as you did in the Project settings / Inputs … but DONT

it seems that once set in the Project settings / Inputs - the axis values (floats) acts as it had started from 0 moving up the +scale instead of neg for left ie 1.0 (not -1.0) = left and right is 1.0(as expected)

if you need screenys or vid let me know