2.5d Game - Rotate Capsule without Rotating Camera

Dear, capsule component is not designed for it. You should use LineTraceSingleByChannel for your purpose as a function to understand if player is facing the enemy.

What line trace does?

Think line trace as a lazer that you are pointing up some point. If it hits something (a class, an enemy), pawn can interact with it. So you dont need to do some extra. Just trace, please have a look. :slight_smile:

About box collisions, you press the trap and entered an area, trigger event like collapse tomb on your players head. Thats on point. So even these two are seems like same,they got distinguish when such ways.

1 Like

Hello everyone!

I followed this tutorial UE4 Tutorial: Paper2D Character (2.5D Top-Down RPG) - YouTube but now there’s one issue: the capsule doesn’t rotate when moving, and I need it to rotate because I want to use a Box Collision to check if the player is facing the enemy whilst attacking.

Also, having the Capsule rotate would be very useful in General, otherwise I’ll have to manually set up a system to calculate in which direction the character is in and hence spawn the Box Collision accordingly.

My idea was to manually set the Capsule Rotation when Moving, but it doesn’t work because the Camera rotates as well, whereas I’d like for it to stay where it is.

Seems simple enough, yet I can’t find a way to do it! :frowning:

Thank you for your time!

Thank you for your answer!

But if the Capsule doesn’t rotate, wouldn’t the Line Trace be somewhat off because the forward axis is always the same?
The Capsule is always facing towards the Camera whilst the Sprite keeps changing as needed, how could I use the Line Trace to help me check if the character is facing the Enemy?

wouldn’t the Line Trace be somewhat
off because the forward axis is always
the same?

No you will draw line trace the where your pawn or camera, to the point that camera heading or skeletal mesh heading direction. You have nothing to do with capsule component.
Here is one sample :

FVector TraceStart = GetActorLocation();
FVector TraceEnd = (GetActorRotation().Vector() * 1000) + TraceStart;
GetWorld()->LineTraceSingleByChannel(TraceHit, TraceStart, TraceEnd, ECC_Visibility, QueryParams)

If you have blueprint scripting for sure you will have equivalent variables and functions with the same names.

Thank you!
It somehow works, but there’s one slight issue: the line trace won’t detect the enemy when it comes close to me, it will detect it only if I press a direction to go against it.
What could be causing this?
I have no idea why the line trace isn’t working properly, I set it to camera channel trace because the enemy is a Pawn

EDIT: Nevermind, I put the Tracing Code in the Movement Handling Section, so it only worked when I pressed the Movement Keys.

Everything is working just fine now, it’s detecting the Enemy Facing properly with a Bool and I can finally move on to other stuff, Thank you!

@Lothex91 you are always welcome. It would be good if you please mark as the answer and upvote the comments that helped for you.

Sure thing!