Jump to content
Andres97

Moving targets in multiplayer / dedicated

Recommended Posts

Hi all.

I've been trying to get a few of the moving target scripts that I was able to find here in the forums, this being one of them.

Problem is, I am part of a milsim community and I'd like to put moving targets for sniper and CQB practice.

The script itself works flawlessly on singleplayer, and it works on dedicated but it skips parts of the rail (ie. it doesn't move correctly, it stays for a few seconds in a position, then skips to another part of the rail). 

I'm thinking it has something to do with locality or such, but can't seem to find the problem and less fix it.

If any of you could help I would very much appreciate it.

Thanks in advance, cheers!

  • Like 1

Share this post


Link to post
Share on other sites

The problem with this script is that it updates the position of the target every 0.01 seconds, causing an overflow of information to stream to clients. I guess that ArmA can't handle so many updates in a short period of time which makes it impossible to have a continuously moving target since it is limited by the engine.

Here's the script so you don't have to download it to have a look at it: @zooloo75

Spoiler

fn_MovingTarget =
{
	private ["_target","_distance","_speed","_dir"];
	_target = _this select 0;
	_dir = _this select 1;
	_distance = _this select 2;
	_speed = _this select 3;
	_pause = _this select 4;
	
	
	while {true} do
	{
		sleep _pause;
		for "_i" from 0 to _distance/_speed do
		{
			_target setPos 
			[
				(position _target select 0) + ((sin (_dir)))*_speed,
				(position _target select 1) + ((cos (_dir)))*_speed,
				0
			];
			sleep 0.01;
		};
		sleep _pause;
		for "_i" from 0 to _distance/_speed do
		{
			_target setPos 
			[
				(position _target select 0) - (sin (_dir))*_speed,
				(position _target select 1) - ((cos (_dir)))*_speed,
				0
			];
			sleep 0.01;
		};
	};
};

 

 

I tried to find out how BI handles it's targets in their mission by dePBOing the first firing drills mission (A3>>Addons>>mission_f_beta.pbo>>Challenges>>Firing_Drills>>SP_FD01.Stratis) and opening it in the editor. I also had a look at the config.bin but to no avail. I wasn't able to find out how BI does it. Maybe it is just like the script above and also has no MP compatible version. This would explain why BI doesn't have a moving target course in MP. 

  • Like 3

Share this post


Link to post
Share on other sites

Thanks for the clarification. Actually this was my first idea. I did know that a while loop can be very demanding and so I tried to make it execute every 0.1 seconds instead of 0.01 and make it move a little bit less, but it still didn't work. Maybe it needs more time.

Maybe you're right and this isn't possible in MP, but let's hope there is a solution.

Cheers.

Share this post


Link to post
Share on other sites

I will be working on something like this, but it will take some time and be clunky, locally hiding a server object and creating a local object and syncing them

Sent from my WAS-LX1A using Tapatalk

Share this post


Link to post
Share on other sites

Great news, let us know as soon as you have something and if you need help with anything!

Share this post


Link to post
Share on other sites

You could use a parametric function paired with an object local to the client to determine the position where the object should be based off of the time. This should offload network traffic and maintain smooth movement for each client.

 

Depending on how projectiles collide with local objects across all clients, you may have to broadcast when the target has been hit, and mimic the hit state to others with their local object.

 

Hope this helps, and good luck! 

Share this post


Link to post
Share on other sites
1 hour ago, zooloo75 said:

You could use a parametric function paired with an object local to the client to determine the position where the object should be based off of the time. This should offload network traffic and maintain smooth movement for each client.

 

Depending on how projectiles collide with local objects across all clients, you may have to broadcast when the target has been hit, and mimic the hit state to others with their local object.

 

Hope this helps, and good luck! 

 

 

That sounds clever but you should give him some working code.

 

Saying 

parametric function paired with an object local to the client 

is not helpful.to anyone.

Share this post


Link to post
Share on other sites
9 minutes ago, das attorney said:

 

 

That sounds clever but you should give him some working code.

 

Saying 


parametric function paired with an object local to the client 

is not helpful.to anyone.

Of course, but just giving out code isn't going to help out in the long run.

 

I'm not in front of a computer to type out or test any code right now.

 

I also disagree with your argument that what I said is not helpful to anyone. Someone who understands what I said and can script this may be able to implement my solution. 

Share this post


Link to post
Share on other sites
Just now, zooloo75 said:

Of course, but just giving out code isn't going to help out in the long run.

 

I'm not in front of a computer to type out or test any code right now.

 

That's fair enough, but this is a fairly complex topic, so if anyone wants to get involved, then it's elbows deep all the way.  :)

Share this post


Link to post
Share on other sites
1 minute ago, das attorney said:

 

That's fair enough, but this is a fairly complex topic, so if anyone wants to get involved, then it's elbows deep all the way.  :)

I already provided a solution, somebody just has to write it. Could be me eventually, but in the meantime, perhaps someone else can take up the challenge. 

Share this post


Link to post
Share on other sites

So you're saying do it locally, but if there's a hit, then sync it up over the network?

Share this post


Link to post
Share on other sites
17 minutes ago, das attorney said:

So you're saying do it locally, but if there's a hit, then sync it up over the network?

Create an object that is local to the client that will act as a target. This can be done with the createVehicleLocal command.

 

With that object, we need to set its position at an interval based off of the current time. This time value must be consistent across all clients to ensure that everyone sees their instance of the target at the same position.

 

With this in mind, we can write a function that returns the position that the target should be at given the current time. This function would take the current time, the starting position of the target, and direction to be applied to the offset position. Figure out the math to calculate the position based off of the current time, and you can then use that position for your target. 

 

When the target is hit, we want the target to do an animation, or something, so we need to add an event handler for when the target gets hit. Since the object is local to the client, we need to broadcast to all other clients when the player hits the target, possible with the remoteExec command. Other clients will then receive this message and should then make their local target perform the desired action.

Share this post


Link to post
Share on other sites
16 minutes ago, zooloo75 said:

Create an object that is local to the client that will act as a target. This can be done with the createVehicleLocal command.

 

With that object, we need to set its position at an interval based off of the current time. This time value must be consistent across all clients to ensure that everyone sees their instance of the target at the same position.

 

With this in mind, we can write a function that returns the position that the target should be at given the current time. This function would take the current time, the starting position of the target, and direction to be applied to the offset position. Figure out the math to calculate the positioning based off of the current time, and you can then use that position for your target. 

 

When the target is hit, we want the target to do an animation, or something, so we need to add an event handler for when the target gets hit. Since the object is local to the client, we need to broadcast to all other clients when the player hits the target, possible with the remoteExec command. Other clients will then receive this message and dhould then make their local target perform the desired action.

 

That's going to be a shitload of network traffic just to have some local objects sync up with each other.  Probably easier to have a global object and use:

 

https://community.bistudio.com/wiki/setVelocityTransformation

 

Or just build a target model with a proper animation to handle all this crap.

Share this post


Link to post
Share on other sites
4 minutes ago, das attorney said:

 

That's going to be a shitload of network traffic, just to have some local objects sync up with each other.  Probably easier to have a global object and use:

 

https://community.bistudio.com/wiki/setVelocityTransformation

 

Or just build a target model with a proper animation to handle all this crap.

What network traffic would there be? The only thing being sent over the network is the event of a client's target being hit, which is barely anything. 

 

Your idea would still suffer from stuttering as the server would still be responsible for synchronizing the position, sending that position data constantly across the network, which when paired with UDP, would result in a high probability of the packets containing the position data to be received and processed by the clients out of order.

Share this post


Link to post
Share on other sites
2 minutes ago, zooloo75 said:

What network traffic would there be?

 

 

Quote

This time value must be consistent across all clients to ensure that everyone sees their instance of the target at the same position.

 

^^ this network traffic

Share this post


Link to post
Share on other sites
8 minutes ago, das attorney said:

 

 

 

^^ this network traffic

Time is already consistent across the clients. It does not need to be broadcasted. As long as everyone joins the game with the correct time (which the game does for you), they'll have the same time being passed to the positioning function, since their clocks will tick at the same rate.

 

Only one piece of information is sent across the network, and that is a signal that the object was hit.

Share this post


Link to post
Share on other sites
3 minutes ago, zooloo75 said:

Time is already consistent across the clients. It does not need to be synchronized. As long as everyone joins the game with the correct time (which the game does for you), they'll have the same time being passed to the positioning function, since their clocks will tick at the same rate.

 

How is time consistent on clients? That would be a shitshower to assume that.  It's all over the place.  As you know, everyone's fps is different, and their PC's perception of "time" is different.

Share this post


Link to post
Share on other sites
4 minutes ago, das attorney said:

 

How is time consistent on clients? That would be a shitshower to assume that.  It's all over the place.  As you know, everyone's fps is different, and their PC's perception of "time" is different.

 I think you're mistaking my meaning of time with a computer's system time. I am referring to the ingame time of day, which would be consistent. 

 

 

Your game may run at 1000 frames per second, but that doesn't mean a second is going to elapse any quicker.

Share this post


Link to post
Share on other sites

The proof is in the pudding, so if you think it is good enough, then make a test mission for this guy and his buddies.

 

No point debating it with me until we are both blue in the face.

 

If it's good enough then fair enough man  :)

 

 

 

Share this post


Link to post
Share on other sites
13 minutes ago, das attorney said:

The proof is in the pudding, so if you think it is good enough, then make a test mission for this guy and his buddies.

 

No point debating it with me until we are both blue in the face.

 

 

There was no point in starting a debate with me about my solution when you admitted that you couldn't comprehend it in the first place.

 

If someone explains how to catch a fish, and I know very little about fishing, then it wouldn't be wise of me to start critiquing the person's fishing techniques.

 

Also, how dare you order me to take additional time out of my day to work on something just to prove you wrong. You have some nerve, bud. I hope I'm just mischaracterizing the tone of your message.

Share this post


Link to post
Share on other sites
Just now, zooloo75 said:

how dare you order me

 

Well why are you posting here in the first place?

 

I assumed it was to help the OP, but if you want to turn it into some kind of power struggle, then carry on.....

Share this post


Link to post
Share on other sites
6 minutes ago, das attorney said:

 

Well why are you posting here in the first place?

 

I assumed it was to help the OP, but if you want to turn it into some kind of power struggle, then carry on.....

I'm posting a solution that might be of use to the right person to further progress the OP towards having moving targets. No where did I say that I was going to provide an implementation of said solution. Especially at 1AM.

 

You seem eager to solve the OP's problem, so I'll give you the pleasure of handling this issue ;)

 

 

Please don't be oblivious to your own messages and take a stance that my response is uncalled for.

 

Share this post


Link to post
Share on other sites

TBH, your solution was big on words, but small on actual code.

 

Oh and it's 7:46AM here.  See - I told you time is never synced ;)

  • Like 1

Share this post


Link to post
Share on other sites
Just now, das attorney said:

TBH, your solution was big on words, but small on actual code.

 

Oh and it's 7:46AM here.  See - I told you time is never synced ;)

Let's just agree that it's too late where I'm at to provide an inplementation, and too early where you're at to write code. Win win?

  • Like 1

Share this post


Link to post
Share on other sites

Win fucking win - apart from the OP and other forum users who get to see handbags at dawn (or midnight from your perspective)

  • Like 1

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

×