Replication ARGH! Effects not showing client side.

  • 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.

Zengi

New Member
May 14, 2004
36
0
0
What does it take for an effect class to show client side. I know bNetTemporary needs to be false and RemoteRole needs to be something other than None. But my weapon's depiction of maps through little effect squares is not showing. The squares are a 2 poly mesh and I can see them just fine. Clients see absolutely nothing. The package is in ServerPAckages, and I believe they see the weapon being held by me, just not the stuff it generates.
 

JamesKilton

UA Coder
Oct 6, 2002
210
0
0
Everywhere and Nowhere
Visit site
Well, the real question here is who owns the weapon that spawns the effect? You can see your own effects because you own the weapon, and thus the function that spawns the effects gets called for you. However, everyone else doesn't own that weapon, so function replication doesn't work.

How do you fix this? Variable replication always works. So what you do is have the server increment a variable (say an integer) which gets replicated to all clients. Those clients will recognize the changed value and spawn the effect themselves. Some code to help you understand:

Code:
var int FireOffset;
var int OldFireOffset;

replication
{
	reliable if (bNetDirty && ROLE == ROLE_Authority)
		FireOffset;
}	

simulated function PostNetReceive()
{
	if (FireOffset != OldFireOffset)
	{
		ClientFireWeapon();
		OldFireOffset = FireOffset;
	}
}

function ServerFireWeapon()
{
	// ... fire weapon stuff
	FireOffset++;
}

simulated function ClientFireWeapon()
{
	// .. spawn effect here
}

PostNetReceive is where to deal with this type of situation. You want to keep the old value as I have or you'll see your fire effect being spawned continuously (why? I don't know. It seems that it should only replicate the values when they've changed). Hope that helps.
 

Zengi

New Member
May 14, 2004
36
0
0
It does kind of. If weapons can only spawn effects on the Owner's machine then why can you see other people's beam attacks etc?
A mutator that is only Server side can spawn things such as weaponry and vehicles onto the clients. Why can't the same thing be done with effects and emitters. The effect is quite complex and has quite a bit of calculation involved. My goal is not to spawn it client side and server side with no replication, I want to spawn it server side and have it replicate properly.
 
Last edited:

JamesKilton

UA Coder
Oct 6, 2002
210
0
0
Everywhere and Nowhere
Visit site
You just can't do that Zengi. The networking architecture only allows function replication for Pawns that are owned by that player. What I described above is exactly how you see other people's weapon effects. You can't see that because it's all native, but that's the system. It sucks, yes, but I'm sure there's a good reason for the choice Epic made. You'll just have to do this, there's no way around.
 

Zengi

New Member
May 14, 2004
36
0
0
If so then how the heck does the Ion Cannon, which is an Actor, spawn the purple projectiles when its RemoteRole is Role_None. Its not even replicated to the client by design so how does it replicate the projectiles spawning ?
 

JamesKilton

UA Coder
Oct 6, 2002
210
0
0
Everywhere and Nowhere
Visit site
Ion Fire is just another weapon, and behaves like one replication wise. The satellite itself is a part of the level and doesn't move, and thus doesn't need to be replicated anywhere. When the Ion Cannon goes off, every client knows about it and spawns one in the right place for that client to see it correctly. It's all the same system.