Hello, I am quite new to unreal engine 5.
Currently I wanted to start the combat system with my 2D third person character. The problem is that the line trace “hits” from the direction from the camera. I want the line trace to hit out of my character.
What is start attack? Just a scene component attached to the player’s something? To what, specifically?
You’re asking for a socket location without specifying which one - is this intentional? If you’re not using sockets, it might be more straightforward to:
Same result (afair), but skips the socket look up.
Since you’re drawing debug trace, can we see it? Essentially, there’s nothing wrong with what we see - the issue must be then where we cannot see. How is the character hierarchy set up?
I would love to show a video, but i cannot send it here so i try to explain.
Here is a screenshot of my character when im pressing the hit button. The Line trace is facing into the direction of the camera and not the direction of my character.
When my character is facing down, the line trace is still going to the direction of the camera. I have the Paper ZD and 2D plugin if that helps. I have made it so that depending on the direction the character looks, the animation is also played to the direction. And I would like to do the same with the attack system, so that the character hits where he looks.
Could we please see the component hierarchy of the character? What are the arrows attached to? You can also make the arrows not hide so you can observe their position at run-time - perhaps this will quickly explain what is going on. This is crucial since you’re using their position for tracing.
I have the Paper ZD and 2D plugin if that helps.
Sadly, I’m not too familiar with those. But tracing is straightforward A->B. I wouldn’t blame tracing itself, but rather the components’ locations instead. And / or the way the rotation is set up.
I dont know if you can see that very well but there are the two arrows. they are facing at the direction of the camera. I will have to do more answers so i can send more screenshots.
Here is the event graph (dont mind the “Is attacking set” boolean)
The start attack is the first arrow that comes out of my character. The end Attack is the Last one.
Edit: Thats it. I dont know what i can show anymore except this. That is the only logic behind the Attack system/Line trace.
The trace is going from arrow to arrow but as i said, the line trace is not looking at the direction of the character. When the character looks down the trace should go down too. Its basically set to the camera direction. Thats what im planning to do. My expectations were not that it would work directly, but I wanted to know how it would work, that is, how I could manage to do it. So don’t take it the wrong way.
Thanks a lot!
As you can see, the trace is still up so at the direction of the camera. But my Character is looking in a nother way, my plan is, that the trace is looking at the same way, where my character is facing.
The arrows are attached to the capsule - they follow capsule rotation. Attach them to another component whose rotation / location you wish them to follow.
When the character looks down the trace should go down too.
If by character looking down you mean the camera direction, you could use that for tracing instead.
How are you rotating the character? What are you actually rotating for directional changes?
Before “Add Controller Pitch input” there is the node “Enhanced Input Action IA_Look”
It couldnt fit in the screenshot. I also changed the movement a bit so it feels like a 2D game.
Gents, not to add noise to the conversation but I always thought that the line trace nodes required a directional vector for the “end”. Both of your examples use a world location instead. Does that work as you expect? I would expect to see the following:
For line trace start
StartAttack->GetWorldLocation
For line trace end
StartAttack->GetWorldLocation + StartAttack->GetWorldRotation->GetForwardVector X scalar distance, let’s say 100
OP wants to trace from A → B, using arrow comps as points for this, instead of direction (I’m ignoring the sockets here, does not seem relevant). In their case, it does not matter where the arrows are pointing, only where they are. And since they are attached to the capsule the way they are, things accidentally line up anyway.