Main Menu

Shoots!

Started by Melssj5, June 18, 2006, 04:37:24 AM

Previous topic - Next topic

Melssj5

Hi, I am going to add some shoots to my game, so... How can I do it. I was thinking on having a preoaded 3d object with the bullet, and when a shot is done, it creates an element inside a list of automotion objects.

My idea is to have a motion objecto that means object3d inside the world that  have an auto movement like bullets or missiles, just giving them a init feature, defined movement and condition to exist, so they will be automatically removed when its done. I was thinking on having a list like this and a thread to move them while the game is running.

Any suggestion?
Nada por ahora

EgonOlsen

Don't put the movement in a thread, as it will cause all kinds of weirdness when rendering and moving interleave. You better make it time/ticks based instead and call the movement from inside your game loop. You may want to have a look at the Paradroidz sources (http://www.jpct.net/download/paradroidz_src.zip) to see how it's done there (That doesn't mean that that's the best way to do it...it's the best thing i could come up with.)

Melssj5

I meant using the RenderThread to move this objects, but I noticed that is not a good idea becausse I would have this list on each client and will be updated only if a new shoot is made, that may be good, but making them client dependent may generate some malfunctions. The performance on  each client may generate some differences about the bullet movements, i mean that one client may see something that another dont. Thats why I better will have this list of shoots on the server and transmit it to the clientes as I do with the crafts. Only position and direction. on this way each client preformance wont affect the whole action. becausee all will see the same,
Nada por ahora

Melssj5

Well, after some years I want to retome this topic again, Any advices about how to do the shoting stuff???????

My game client have 2 main threads, the renderThread (rendering) and the EventManagment thread (manage all the interactions). My game server has one thread for each client, all the clients share the same world when collisions between players are checked.

I was thinkig on having a list of newly shots for each client thread on my server, and this list is transmited and cleaned on each iteration. The movement will be done on the game client and is the life amount changes then it will  be notified to the server.

Any suggestion or advice?
Nada por ahora

fireside

I thought you said you had a job or a life or something and didn't have time to program anymore?  The car demo has shooting in it. 
click here->Fireside 7 Games<-

Melssj5

yep, I just can assign few hours a week (Sunday at night) to do this. Thats why I want to do the shoting stuff as light and fast as posible.
Nada por ahora

paulscode

Quote from: Melssj5 on April 14, 2008, 03:27:40 PM
I was thinkig on having a list of newly shots for each client thread on my server, and this list is transmited and cleaned on each iteration. The movement will be done on the game client and is the life amount changes then it will  be notified to the server.

Any suggestion or advice?

I was thinking - You might have some delay problems.  I can think of a couple of ways to work around this.

One way would be to create some kind of timing system, where the server knows what time each bullet was fired.  The server would tell this to all the clients so they can synchronize the bullet's correct position on their end.

The second way would be for the server to calculate each bullet's position.  The server would be in charge of "moving" each bullet.  It would tell all the clients where the bullets are located.

The other thing I was thinking, is you should give each bullet a unique id number.  That way you won't end up accidentally making two of the same bullet.

These are just a couple of thoughts I had, I don't know if they would actually work for what you are doing.

EgonOlsen

#7
"They" say: Do all this stuff on the server, don't trust the client. That said (i had to say it, because everybody does and it is true to a degree), here's how i'm doing it in the "nameless Bomberman clone". That doesn't mean that its the best or even a clever way to do it, but it is, what i came up with after trying some things.

Each client manages its own entities. These are the entities that have been created by that client by the local player shooting, placing a bomb or a local bomb exploding. Except for the explosion, which i treat differently (but that shoudn't matter here), each client transfers its entities to the server in each iteration. The server is sending them back to all other clients in return (after doing a sanity check in some cases). An entity contains position, orientation, animation information, movement speed,... in a quite lean way, so the overhead of transfering them every time is negligible.
Between the iterations, the clients are interpolating the movement based on the last server data to provide smooth transitions. All entities have a unique ID combination consisting of clientID and objectID. If the server doesn't transfer an entity in an iteration, the clients will remove it from their list. With this, the server doesn't have to make the client explicitly remove objects.

Collision detection between local and remote objects is done on the client that has created the local one. The server does a (quite dump) sanity check to see, if this is actually possible.

Melssj5

Thanks for the replies. My first idea was doing all the stuff on the server as Paul said but I am worried about the performance of transfering all the bullet information about internet, Actually my spacecrafts are moving on that way. The server manage all the collitions and movements in a shared world, then the info about position, direction, and the rotaion matrix of all the crafts are being transmited to each client (about 131 bytes per client for a 3 players game).

If I consider that each player may have 10 shoot bullets on a certain time (I am an unreal tournament player and pleople shot as if there were no tomorrow), this mean that there will be 10 times more information to transfer to each client on each interation while the bullets exists, this mean that 131 bytes will go to 1441 bytes on each iteration (120 miliseconds aprox), and thats a lot to tranfer via internet. in a LAN there might be no problem.
Nada por ahora

EgonOlsen

Have you considered to zip the stream? In "nameless...blah bah", both, the server and the clients, can zip/unzip the data is this is enabled. It's just a flag at the beginning of the stream that tells the stream reader if the rest of the content is zipped or not. It helps to save a lot of bytes for the price of a higher processing time, but that hasn't been a problem so far for me.

Melssj5

ok I will do all the stuff on the server and zip before sending. Actually only my targets have a CollisionListener added. Bullets will live until reaching any target. My actual targets will be:

the crafts
the map limit (an empty box arround all my map)
the mountains

Now I need some explosion animations to use in my project.
Nada por ahora

raft

well, best to say first: i haven't ever implemented such a thing but i thought and read a lot. here are my two cents:

* forget about running such a multiplayer action/shooter or similar game over internet. no matter how fast internet is now, they're still not playable. the possible lag is very annoying for such games. UDP is not reliable over internet and TCP will cause even more lag

* for bullets, missiles etc i would possibly take this way: instead of sending their position/direction/velocity on each iteration, send initial position/direction/velocity and let clients calculate the rest. maybe fire time can also be sent for synchronization as paulscode said below. bullet hit test can be done on either initiater client (as Egon's) or on server. btw, doing no 3d calculations on server makes it very very light. karga's server + tomcat was running with 16m memory (cheap hosting) for quite a time. i've even seen up to 30 users and all was good

* for iterating/interpolating over a path you may use PathIterator of jKilavuz. this is free part of it and uses karga path system behind the scenes ;) for example:
PathIterator pathIterator = Paths.linearSegment(direction, from, to, -1);
and on each frame:
if (pathIterator.hasNext()) {
    PathPosition position = pathIterator.next(timePassedSinceLastFrame);
    myObject.setLocation(position.location);   
    myObject.setDirection(position.direction);   
}

you may also create curved and accelerated paths and even merge any two paths into a single one.

r a f t