DrawDebugCamera from gun position drawn facing wrong direction

At 05:35 we test drawing the debug camera using DrawDebugCamera using the location \rotation of the Gun via GetActorLocation\GetActorRotation.

The Drawn Camera is placed at the right location in the viewport but noticed that the camera image is not pointing in the same direction that the player gun was pointing, seems to be drawn at approx 90°. from the direction the gun is facing.

I noticed this in the tutorial as well.

Is it something to with the gun being attached to a socket ?

  1. What version of UE are you using?
  2. Could you show screenshots and code please?

I’m using Unreal v5.1

Screen shot 1: from Tutorial

image

Screen Shot 2: from my implementation.
It spawns from the gun so player moved back so camera can be seen.

Code placed in Class Weapon (called: Class Gun in Tutorial).
This Function Called from PullTrigger()

Is screenshot 2 without moving the character after shooting?

After pushing Fire (Left Mouse) the camera was drawn as shown.
For the screen shot I moved back after pressing fire , the player was moved a few steps backwards (not rotated) as the player was obscuring the view.

Upon inspection that’s the correct rotation and nothing to do with being attached
image
Note the X direction.

I’m not following, could you explain please.

The positive x direction is forwards and you can see in that screenshot which direction that is

I started to do some digging and found that imported models are using the +Y axis (mostly) to represent forward direction and unreals own components are using forward direction with +X.

My finding are as follows

  1. Imported Asset Rifle: Points forward on the +Y axis for both Global \ Local Axis

image

  1. Unreals components: Camera & Spring Arm both points Forward on their +X Global\Local Axis

  2. Imported Asset Skeletal Mesh: Wraith_OD_Green: Points forward on its Global +X axis but also points forward on its local +Y Axis ?

So in conclusion, the built in Unreal components such as Camera+Spring Arm use +X as there Forward Axis and imported models seems to be using mostly forward as +Y

As the DrawDebugCamera is a built in function, I assume it also using the X axis as its forward direction
which why it facing at 90 ° from the forward position of the gun?

Does this seem right?

One last query, Why are assets importing with different axis for forward vectors to that of Unreal?

The gun is pointing in +Y but it’s still facing +X, what you think is the front of the mesh isn’t the front.
That red arrow in your first screenshot is showing its forward vector.

I can see what direction x is facing, but all that means to me is that when the Rilfle asset was exported from what ever created it, it was not set to have its x axis pointing to the correct forward direction of the model, it is the artist that should decide that right.

As feedback to this beginner course these sort of things need to be explained far better than what has been covered, I still dont understand how the Rifle is even pointing in the right direction, as from what we’ve been discussing the Gun should be moving forward on its side.

I guess this discussion , is moving a little away from the course material so thanks anyway for your responses, I have some other courses to do after I complete this one so perhaps it will be discussed there.

1 Like

What are you attaching this to? What direction is that facing?

Line trace using the forward vector of the bone (red) and gun (green)

I’ve just watched a introductory video from epic on skeletal meshes, it lasts approx 18 mins and contains some really useful information.

The answer to my question of:
Why is the debug camera drawn 90° from the position the gun barrel is pointing?
Answer: Because unreal uses the +X axis as its forward so the debug camera is pointing forward on the X axis.

I also asked.

You said:

This answer could of been clearer , because though the gun is using the correct rotation, it is the socket that is controlling the guns relative rotation and location so it does have something to do with the direction its pointing.

1 Like

I said that earlier

Yes, sorry. What I was trying to say was that it’s not the attaching itself that is why it’s that direction i.e. it would still be that direction of you didn’t attach it.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms