PlayAnim in client side weapon

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Grey Harverton

New Member
Dec 5, 2001
10
0
0
Australia
I have created a function that reloads my weapon when I press a key. It does everything correctly on the client side except for playing the animation associated with reload.

The playreload function is a simulated function and it 'gets into' this function because I have put log messages into all my functions and states to make sure. Plus the functionality of reload works fine as it puts new bullets into the clip. Any thoughts on why this might be happening?

Incidentally, the weapon works perfectly in single player and with server side players.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Try something like this:
Code:
replication
{
    reliable if (Role==ROLE_Authority)
        ClientPlayReload;
}

function ClientPlayReload()
{
    <play reload anim here>
}
ClientPlayReload() can be called from the server but always executes on the client. Just call that function where you want the weapon to reload.

But simulation is a difficult thing. If this doesn't work post your code and we might be able to locate the problem then.
 

Grey Harverton

New Member
Dec 5, 2001
10
0
0
Australia
Okay that works, but only if I had ClientPlayReload as a simulated function. Would that be right? Up until this point I understood all the code I was writing for this weapon.
Let me see if I understand this correctly:

Whenever we say "reliable if (yada yada)" we are telling unreal when to pass a variable or function from client to server. So in the case of "Role==Role_Authority" we are saying, "when this code is executed from the server side, inform the clients about ClientPlayReload when it happens..."
If that is correct it seems wrong to me. Surely if my reload function is executed on the client side (ie by the client pressing a button) we should have "Role<Role_Authority" in other words - "when this code is executed on the client side inform the server about it"...

Have I totally missed the point? Please don't laugh if I have.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Pretty close.

Unreal (Tournament) acts differently for variables and functions there.

Variables:
- reliable/unreliable is the same
- Role==ROLE_Authority means server passes variables to ALL clients

Functions:
- reliable/unreliable is NOT the same (reliable makes sure the function reaches the client)
- Role==ROLE_Authority means server passes function call to ONE client (to the player owning the weapon/item/whatever)

For full detail read here:
http://unreal.epicgames.com/Network.htm