Rotate the character 180 on the Y axis in a 3d side scroller to make it run on the opposite way

Hello everyone I am making a 3d side scroller and I don’t know how to flip in the opposite Y axis the character while running,could you help me please?

1 Like

Hey Domenico_Pentangelo! I put together a small example for you using logic blocks, I hope I understood the question correctly.

So we have two variables for the player, the direction the player is moving, which gets set when you press the direction you want to move in and the second variable keeps track of the players rotation.

Then using some simple logic, compare the direction to the current rotation and rotate the player and adjust the rotation variable if it does not equal what it should.

I also included the demo but it was made on the latest UPBGE so I included the logic above if needed in case you couldn’t load it.
rotate_char.blend (539.9 KB)

2 Likes

have a vertex parented empty on the player’s hitbox,

add an empty to the left side of the player

add an empty to the right side of the player

parent these to the empty parented to the player.

use TrackTo actuator

if Bool facingLeft = True--------------and------------Track to left object
__________________ \ --------------nand-----------Track to right object

2 Likes

Interesting solution BluePrintRandom so I implemented your version.

I like how with track to I can set the track time. The down side is that at around 20 frames of track time the last part of that tracking tapers off more slowly then the initial rotation. 10 frames worked nicely without noticing that effect. Also im not sure if you could force it to rotate with a forward bias to the rotation this way (so that the player would face the camera, if needed).

Pros: Simpler logic with less variables to mess with. Easier to adjust rotation speed.
Cons: Track to motion not linear, noticeable at larger intervals. Can’t set a rotation direction.

rotate_char_track_to.blend (545.8 KB)

1 Like

thank you so much Ethicalfive ! I’ll try what you sent me… thank you this is really helpful

1 Like

thank you so much for you answer BluePrintRandom! this is so helpful!

thanks so much to everyone, you made me understand this, where did you learn blender game engine?

I learned by tinkering and asking questions here when I got stuck :smiley:

1 Like

hey there, after trying to use BGE I learned game maker studio 2 , and now I am working on my first 2d game project but BGE has always been so interesting to learn, I am giving it a try again by using the UPBGE. I will surely ask questions on this very helpful website!

here is the upbge discord too in case you need quicker response

2 Likes

Personally I use tap methods with applyMovement() & radians for 180deg-like-swat-turns.
Oof, did not see the previous posts marked 2019, nvm ^^

1 Like

Hey there, thank you!

thank you!