Discord
Login
Community
DARK THEME

How to update network shots?

Hello,

I managed to make a network game where some players are updated. The player is updated in the client and then sent to the server, where a list with all players will be sent to the clients.

The players on the server have the client id as index.

Player drawing and network player drawing are separated in the client. Player draws from local variable.

But how can i make shots for all players in the network, which can collide and be removed?

Actually I make a "new bullet" message if the player presses space bar. The bullet info will be sent to the server, which adds it to the bullet list.

I would like to update all bullets in the server but serverUpdate gets not called all the time but only when the server has something to process.

So I need to update all the bullets in each client (?) How can I register that a bullet has to be removed? All clients would send a collide message at the same time to the server as far as I see. When a bullet collides on the one client with a wall, it would collide on all other clients, too.

Bullets on the server have NOT the client id as index...

I am a little bit stuck.

Anyone who had same problems?

It's my first network code.

I copied it from microVerse project. I added, that the player only updates when something changes, to save network traffic.

Short: I can MAKE bullets in network but I don't know how/where to update them, remove them and collide them with walls and players (that should work with the local player, Idk - but the walls?), synced with the server and all other clients.

Thanks in advance for your suggestions.

Basically bullet collisions need to be done server-side also bullets need to be stored and removed server-side...
You can explore network code from space-shooter game Asteroids FFA by @gilles.

Thank you, I will look into it.

[EDIT]

After looking at it, I see that it is done in serverUpdate. I already did this, but.. My serverUpdate does not update all the time, Idk what happens here.

I need to review that again (with some print commands).

[EDIT 2]

I made a dumb mistake, forgot to write "serverObject." before sendBullets(). :) And then I thought it will not updateServer - because sendBullets only was called by creating one.

Now it works.

Will be published soon. ;)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community