Example: For detecting damage for a weapon (replicated) I save the location (getcomponentlocation) every frame from a scenecomponent attached to the weapon mesh and do a line trace from the current position to the position last frame. This is working fine when launching the game as listenserver with any number of instances (1-4 replication works as intended, which means the collision detection from the line traces detects when a pawn is colliding and applys damage accordingly). The headscratching starts when I launch as client, because all of a sudden, the position received from GetComponentLocation() stays always the same wheter the weapon is moving (due to an animation swing) or not, unless the whole character which holds the weapon is moved. The whole linetrace mechanic is kept inside a authority check clause, to only run on the server. Can anybody explain to me why this is happening? I you need any further info pls ask and I will gladly answer as good as I can
I think that when you’re running as a client you’re without server, so the client isn’t seeing the updates as they would normally occur on the server. It’s a good way to check how the client may behave without the server authority.
So it may be a normal behavior because it just doesn’t know what it’s supposed to do without such authority. It’s a lot to take in from your post so I could be mistaken here.
I suspect you are using this optimization setting, on your weapon mesh or at least one of the skeletal meshes your weapon is attached to?
If that’s not the case, discard this answer.
When running as a client, it launches a dedicated server in the background for your client(s) to connect to. Dedicated server never renders anything. If you use any of these optimization (other than AlwaysTickPoseAndRefreshBones) on dedicated server, your skeletal bones are never updated, nor their attached components locations.
I only know of two solutions here :
-
Change setting to AlwaysTickPoseAndRefreshBones on dedicated server. You can keep optimization on client side, but you’ll have to switch it in code. This is the easiest to work with as you don’t have to do anything else.
-
If performance is crucial and it does have a noticeable effect on server load, you can try to use AlwaysTickPose only. However, whenever you need to access bone or attached component location, you’ll have to manually call RefreshBoneTransforms() on all attach-parent skeletal meshes.
you are a saint you saved me a lot of pain, but why would somebody want to render a skeletal mesh on a character statically?? I know the server does no rendering but at least it should simulate postion changes of the bones, otherwise every collision detection via traces are basicaly a mess, and I was wondering the whole time why my hit detection was so buggy… you saved my day