Jump to content
Fiodor

MP setPos Locality - Killhouse Script

Recommended Posts

Hello, I've been trying to create a shoothouse for my community but I've run into a very strange problem. Attached below is the mission file.

 

I've made a collection of scripts to create a CQB enviroment with randomized entry point and random target placement. Works fine in SP (so logic is a-ok) but I've tried to test it in a non-dedicated server and alas not only the doors are not inmediately moved, but the targets are sometimes not moved at all; actually, the targets are moved in the host machine just fine, but  the other player only sees the target in the new position once the host has shot it or after some random delay.

 

Currently the scripts are triggered via addAction, which executes via execVM, scripts that change the position and direction of the objects syncronized. As I said, the logic works as intended in SP, and for whoever is Server when in coop, but the other players experience the aforementioned delay in object movement.

 

As far I've understood it, effects of setPos are global and broadcasted so if my script only makes use of that command (and setDir), why is it experiencing this delay?

 

 

You can download the mission here.

 

Any help would be appreciated.

And, thanks for reading!

 

These scripts may be used in part or completely only when due credit is given.

Share this post


Link to post
Share on other sites

Spamming setpos over net is always a bit laggy. You can reduce that by running the function that moves the object on all clients simultaneously.

If you're moving physics enabled objects you can also include setvelocity to make the movement smoother.

 

If you want it extra easy can also make use of this command:

https://resources.bisimulations.com/wiki/setVelocityTransformation

Share this post


Link to post
Share on other sites

Spamming setpos over net is always a bit laggy. You can reduce that by running the function that moves the object on all clients simultaneously.

If you're moving physics enabled objects you can also include setvelocity to make the movement smoother.

 

If you want it extra easy can also make use of this command:

https://resources.bisimulations.com/wiki/setVelocityTransformation

An example of this could be callling the script that executes the position change with remoteExec ["fn_scriptMoveObjects"], with no second parameter, inducing the execution of such function/script on all conected clients, right?

I'll give it a try, I though making the server do it would be more efficient, and since there's a selectRandom in there it might make different selection in each computer. Please correct me if I am wrong.

Share this post


Link to post
Share on other sites

Arn't those just scripts that move objects around to simulate sliding doors. Why would you need a "selectRandom" for that ?

Anyway, if you need something randomized, simply do that on the server beforehand and then pass the result as a parameter for the script.

 

 

 

Normally you would be right, it is good practice to keep most scripts serverside only. The exception to that are scripts with visual effects and/or effects that have to be updated often. To reduce network load its better to just pass the settings to the clients and run the scripts there.

Share this post


Link to post
Share on other sites

Hello Tajin, thanks for replying with more info; to be more specific, let me tell you:

One script selects an object at random, and moves it upwards, out of the way. Movement is not supposed to be smooth, it should just 'pop' upwards.

Another script, goes through a collection of objects (which act as position markers) and places and orients targets in the same positions as those objects. Again, movement here is only placement, no animation required. Targets should just appear there.

 

Problem for both is that sometimes when co-op hosting, the host sees the changes instantly and in other clients the changes reflect, sometimes, after some seconds (upwards of 10) or sometimes only when the host interacts with the objects (generally when targets have been shot) are the positions updated (and sometimes not even that makes the positions update). In singleplayer these missions, works like a charm.

 

Another doubt that I have is, if 'setPos' is global, then shouldn't it execute on all clients? or perhaps it is a matter of running the script in an unscheduled enviroment? Even then, there shouldn't be that much delay between updating position between clients.

This is really a head-scratcher, if somebody could provide some insight, I'd be really thankful.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×