drawportal() over network

Discussions about Coding and Scripting
Post Reply
User avatar
Voodoo Doll
Average
Posts: 42
Joined: Wed Aug 03, 2011 2:27 am
Location: Russian Federation

drawportal() over network

Post by Voodoo Doll »

Hello all. This is diagram of my camera for D3$TR0Y3R:

Image
Let's me explain how it works.

Once user touched radius of camera trigger (we will call it picture receiver further), it spawns controller and gives it to user's inventory. The controller is used to catch user keyboard input, i. e. select next/prev cam, or zoom (since we can't define exec function xxx() in trigger class). Then, receiver spawns HUD with target variable and sets in this variable self. There is a function in trigger, which puts camera feed on user's canvas. This function is called from spawned HUD's PostRender() function, like in MarathonMod cameras.
After user was leaved receiver radius, HUD and controller are destroyed.

It works offline perfectly, but not online. I've tried to replicate HUD handler of receiver to server, and receiver target variable of HUD to client's, but I even not sure that user gains HUD object at all (in case he is, I should at least see text line on HUD which tells name of target, if client hasn't get it, it should be None, but there is no HUD at all). And again I asking my big question: what should I replicate?

if the source code is needed, I can post it later. I've tried to explain my problem as simple as possible.
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: drawportal() over network

Post by Higor »

This method changes the structure, but it will most likely work.

Make a clientside HUD mutator > Have it register ONCE on the client > Add a variable to reference the Controller (var xxxx CamController).
NOTE: Make sure you don't break the PostRender(canvas) calls on the HUD mutator, at the end (or beginning) of the function, call NextHUDMutator.PostRender(canvas) if there is another hud mutator.

Controller > Add an actor reference (var actor TheCamera) and a switch (var bool bIsWatching) > Add both variables to replication block (Role==ROLE_Authority).
Controller > Upon being spawned on client (PostBeginPlay and/or PostNetBeginPlay) find the local HUD mutator, set this mutator's CamController to SELF.

Hitting trigger > Spawn (or locate if existing) controller (pickup) > Spawn camera (if not existing, bAlwaysRelevant=true) > Set the Controller's TheCamera to this camera and bIsWatching to TRUE.
Leaving trigger > Locate Controller in inventory chain > set bIsWatching to FALSE

HUD Mutator again > If CamController exists and has bIsWatching=TRUE, draw the portal.

Possible issues:
-Dynamic actors in front of the camera won't be relevant during replication, so you won't be able to see them.
-The only way to extend a player's field of relevancy is by setting the ViewTarget to a nearby actor, but that beats the purpose of using DrawPortal.

Registering the mutator can be done using special purpose actor placed on the map:
- If placed in unrealed, RemoteRole=ROLE_None, use PostBeginPlay() and set a 5 second non-looping timer...
- If created by a mutator, RemoteRole=ROLE_SimulatedProxy (bAlwaysRelevant=TRUE), use PostNetBeginPlay() to set a 3-5 seconds non-looping Timer...
(UTPure delays the creation of a hud so this is safe) On the Timer() locate a PlayerPawn whose Player variable is a 'ViewPort' class to determine it's a local player, if this player is a local player proceed to create the HUD Mutator.

The HUD Mutator doesn't have to be destroyed, the controller can remain on the player for future uses.
Post Reply