Aim Offset Issue with Flashlight

I’ve set up the Aim Offset correctly, so my character’s head moves up and down as expected. However, when I test it from another player’s perspective (setting player count to 2), and I look down to shine the flashlight at my feet, the flashlight appears to be pointing forward for my second character, as if the Aim Offset wasn’t applied. It also looks like the light is coming from a point farther away than it should. Does anyone know how to fix this?

The light transofrm is not replicated over the network.

Don’t exactly your setup but assuming there is a lightshource in character hierarcy, so when mouse moves and transforms camera, you have to replicate camera forward vector direction over the network to all clients light source. So they look same direction.

Aim offset being replicated as animation but think your light source in character stays same.

To solve it you can use multiple ways.

*Correct Way : Use networked movement
*Ok Way : Bind your light source to a head socket.
*Hacky Way : Animation update sets light direction in character.

Looking nice btw :slight_smile:

Camera transform is already replicated. You do not need to manually replicate.

Base Aim Rotation, Control Rotation, or Camera Manager → Camera Rotation should be used to update the light transform. Technically it just needs to be attached to component that already uses one of the above.

I figured out that I just needed to untick “Use Controller Desired Rotation”, which made the flashlight aim correctly and appear properly from the second player’s perspective. However, now my entire character floats off the ground when I look up and down.

1 Like

As @Rev0verDrive also mentioned you can just set LightRotation to CameraRotation on tick or attach.

Or you can attach your light to camera will solve it.

You can “Use Controller Desired Rotation” too which will get controller rotation as character transform to solve some problems however their purpose is something else that you should be aware of which is now your controller in charge of your pawns transforms. Design wise can be however it is a choice of another subject which is movement.

You can use that as well, however I would like to put you in the right direction of actually doing things. I am pretty sure if you poke around you can do it other ways too.

I have a default character and added an arrow to it. Arrow works fine till networking.

To replicate its movement over the network I just do 2 functions.

Goes server and replicates it, read the notes for understanding what is going on.

Result is :

123

2 Likes

Base Aim Rotation is what you want to use. It holds the rotations that “Aim”, which is always center of screen…What the player is looking at.

This is the node used when doing an aim offset. You can use control rotation, but Base Aim is better.

As mentioned previously you do not need to replicate controller rotations (pitch, yaw). The controller class already does this (C++).

Your code is doing lock step movement. Move → pass data, server calls multicast. If you have a high ping there will be a visible delay to the movement of the light.

delays = Full ping + server tick + game thread + render thread

Simply attach light to the camera or head bone. Use Base Aim rotation in the Aim Offset math.

1 Like

I need to note the Camera’s Rotations on Simulated and Server Proxies are not updated.

e.g.
If I attach a flash light directly to the camera component it will only rotate (Pitch, Yaw) for the Autonomous proxy. Copies of your character on other simulations and the servers authoritative proxy will not apply the rotations to the camera component.

In fact the cameras location on both sims and server is always in its default location. Take crouching for example. Do a line trace from camera while standing and one when crouching. turn on the debug so you can see it. RPC the server to do the same.

Both traces on the server will look as though you’re standing.

what you want is the following.

To get this to work correctly you have to use the Camera Manager → Camera Location.

Here are some snippets from one of my multiplayer projects.

Setting Aim Pitch & Yaw in the Animation Blueprint.

Where I have Proxy Role switch you can replace with an is locally controlled check.
This will work perfectly on dedicated server setups. Listen server is different because the host client is also the server.

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