

|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
We have a ship and we want it to shoot 4 cannons out of each side and one to the front. Before shooting there's an expected FPS of around 900-1000. Firing all cannons at once drops this to 200. We plan on having multiple ships on screen at once, so this frameloss is pretty bad. Here's how we're firing. In the boat code we have:
loc is the location of the ship. Dir is switch to determine which direction the cannonballs should shoot in. -11 is a multiplier (not important for front cannon) --- Cannonball code:
This is for the Forward shooting cannon. It determines where the cannonball is to be spawned and what direction it is to fire in, based upon the boats location and rotation. Reality's built in gravity is too heavy for the cannonball to go far enough (If anyone knows how to adjust the gravity, do tell me!), so we had to find another way to kill off the cannonball. Tried three ways, reduce its velocity, reduce its Location.y or set up a killtimer. All three generally work the same:
Any suggestions/wisdom/advice would all be greatly appreciated... ...except "use C++" lol. Due to time constraints, learning C++ isn't an option I'm afraid. [This message has been edited by skynes (edited June 19, 2007).] [This message has been edited by skynes (edited June 19, 2007).] [This message has been edited by skynes (edited June 19, 2007).] [This message has been edited by skynes (edited June 19, 2007).] |
|||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
Have you tried debugging or profiling to see what code actually gets called and where the bottleneck is? It could be doing something unexpected like executing that code multiple times, etc. ------------------ |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
Debugging this thing is a nightmare, despite it using MS Visual Studio, we can't use that break point thing, because it doesn't actually RUN in Visual Studio. I've played with the side cannon code (the one really causing bother) The Boat does this:
This, along with the above post spawns 4 cannonballs at 0.5 forward, equal to ship, -0.5 and -1, in other words it looks like a broadside. |
|||
|
David Lancaster Member Posts: 276 From: Adelaide, Australia Registered: 05-22-2006 |
Are you using C# or C++. I heard from Patrick that by using C# with RE, it will use 4 times processor power that full detailed rendering uses, that's alot. Apparently you have to stick with C++. |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
Just worked it out. I changed all the cannonball names to unique names. No more heavy FPS loss... DOH. |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
quote: It's C#, we don't have the time to go to C++ While the topic is open, does anyone have any nifty tips and tricks regarding reality they'd care to share? Obscure code, undocumented functions, that kinda thing. anything an arcadey pirate ship warfare game might need, lol. [This message has been edited by skynes (edited June 19, 2007).] |
|||
|
HanClinto Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
quote: Have you considered using an array or a list?
Just a thought -- it could possibly make it easier for ships to fire varying numbers of cannonballs in the future to use something like a list to store them all. Good job figuring it all out though! --clint |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
Seems I was wrong. Still a framerate problem.
Removing that line allows me over 600 cannonballs with 400FPS. However cannonballs do not move. Having it allows me 20 ish to 300FPS. Cannonballs will move. Any thoughts? |
|||
|
GUMP Member Posts: 1335 From: Melbourne, FL USA Registered: 11-09-2002 |
Best place to get RE (Reality Engine) help is the REC (RE Community): http://www.rendernetgames.com/phpBB2/ This is unofficial help since Artificial Studios no longer officially supports RE. Paul aka LordsWarrior (who is a Christian, btw) runs the site and he'll check you out for getting access. Just mention XrucifiX. |
|||
SSquared![]() Member Posts: 654 From: Pacific Northwest Registered: 03-22-2005 |
quote: Wow! That's strange...and frustrating. Try putting each cannonball on its own thread. May help a little. Does each new cannonball cause a hit to the FPS or is it just the first one? Does each new cannonball cause the same amout of framerate loss? Does the physics code have any static data which may get messed up if multi-threaded?
quote: Different types of ships. Big, bad, but slow. Small, weak, but very nimble. Different types of shots. Check out Sid Meier's Pirates for an example. I thought the ship battles were a nice blend of arcade and action. Don't make it overly complicated. Or the opposite: Make it simple. Some of the pirate/ship games I've played are so involved I never really got passed the first tutorial. They tend to serve a small niche of players. Pirates, on the other hand, is very simple and very accessible to even the casual gamer. |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
quote: Yep, I'm guessing it's because Reality uses VS for scripting, but to run the game you run its OWN Builder.
quote: How do you mean?
quote: The Expected FPS flickers up and down constantly, so its impossible to tell precisely. Shooting one cannonball you don't notice. When you shoot 4 it's very noticeable.
quote: I've no idea. I don't understand how the underlying physics works.
quote: Got most of that. Since we only have 8 more weeks, we're keeping it very simple. Basic speed and strength power ups.
quote: We're aiming for more frantic geometry wars style
quote: It will be very simple as it's only a demo. We've to make enough to show the idea and how it could progress. |
|||
|
HanClinto Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
Like Gump said, I think the REC forums are likely your best bet. Another thing to check would be to see what flags/options you've got turned on for the cannonball objects. Are there such things as "collision groups" in RE? Basically, groups of objects that they can collide with? You'll save yourself some time if only check as few collisions as possible (I.E., don't check cannonballs against other cannonballs, only against ships, and possibly the terrain) If you have very accurate physics (such as inertia, rotation, wind friction) turned on for the cannonballs, that might be slowing you down as well (since physics are processed in the tick() function as well). Also, if the engine has to make a special call into managed code for each tick() function, you might save time by doing a single TickCannonballs() function that calls a tick for each cannonball in a single call. Just some thoughts. --clint |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
Clint, I hand you a cookie. Any size you want, choc chip, nut, cinammon. whatever.
Expected FPS sits over 1000 with me spamming cannons. [This message has been edited by skynes (edited June 19, 2007).] |
|||
SSquared![]() Member Posts: 654 From: Pacific Northwest Registered: 03-22-2005 |
So you did not write any of the physics code? OK. So you don't really have access to know what is happening inside of base.Tick()? Regarding multi-threading... Right now, if your game is not multi-threaded, each cannonball Tick is run one at a time. Cannonball A does its Tick, followed by B, then C, etc. In multi-threading, you can have multiple cannonballs processing their Tick at the same time. Even better on a multi-processor machine because each processor can process these multiple threads. So, while A is calculating its physics on thread 1, B is calculating its physcis at the same time on thread 2. My favorite site for tutorials/examples is CodeProject. Here is an example of Threading in C#. Since I have no idea how the cannonball Tick gets called (part of the framework? some timer?), I can't quite give an example of how you may use the Thread, but it may be something like requring you to create your cannonball inside of the thread. The threading idea is not necessarily the ideal situation for your game. It sounds like there is some other fundamental issue which needs to be resolved. Multi-threading may improve performance, but it may also be masking an underlying issue. Also, how many ticks are happening per second? Maybe the tick is happening too often. Try for 10/second first and see if things improve. If the tick is somehow tied to the actual FPS, then you will be processing a lot of physics, indeed! You don't necessarily want the tick to be equal to FPS. EDIT: Aaah, looks like you have an answer! Cool! [This message has been edited by ssquared (edited June 19, 2007).] |
|||
|
GUMP Member Posts: 1335 From: Melbourne, FL USA Registered: 11-09-2002 |
BTW, the most recent Artificial-based build of RE includes a more comprehensive performance counter so it's easier to determine bottlenecks. ------------------ public class Politician extends Man {public void doSomething() throws UnreasonableException {throw new UnreasonableException(convenientExcuse);}} [This message has been edited by gump (edited June 19, 2007).] |
|||
|
HanClinto Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
quote: w00t! A cookie sounds wonderful -- though I'd settle for a high-five should we ever meet at one of the CGDCs. --clint |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
I did an entire semester of concurrency, so I'm familiar with multi-threading. However with this engine I don't know how multithreading would work.
the documentation in a word... sucks, so it'll be no help. With the adding of a collision group I've got the ex FPS to 900 with spamming cannonballs. Much better than a drop to 300. But still creating 9 Actors shouldn't drop the FPS that much, soooo more optimizing!
quote: I tried limiting the number of ticks in the cannonball. The cannonball stopped moving, lol. Without base.tick there's no movement. So reducing the Ticks, reduces the movement. ---
quote: If I ever know I'm going to one, I'll let you know first |
|||
|
Randall Member Posts: 44 From: Sacramento, California, USA Registered: 06-19-2007 |
I use 3D Gamestudio, so can't help you with the reality engine. ![]() But,
quote:
Gee, well I guess I'd better switch engines. |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
quote: One single ship shooting dropped it to 200 FPS. On a dual-core PC with a Geforce 8800 graphics card. Now imagine a full game with 20+ ships all firing at once. Death by lag, lol. Further changes: I was using the same name for each cannonball i.e.
quote: By giving them unique names I was able to save another couple of hundred FPS. We did have a particle trail on the end of the cannonballs. Even with these changes including it dropped FPS from 1100 to 200 again... Our MODELLER of all people looked at the code and said "Here's your proble, you're recreating the particle trail every Tick!" As so I was... making a whole new particle trail and destroying the last one every Tick. Bad bad bad... So we made a particle trail as a hash, then just moved it. Shooting 9 cannonballs, all with trails drops FPS from 1100 to about 1000. Vast improvement. |
|||
|
GUMP Member Posts: 1335 From: Melbourne, FL USA Registered: 11-09-2002 |
quote: Or just do something like:
And in the definition for cannonball have something like:
|
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
^ Thanks, I'll check that out next week. --- I made a big personal accomplishment on Friday. This is a 3D game with a third person (ish) camera. Thus hitting objects screws the camera over cause it's now outside the game boundaries looking in. Very bad. So I've been toying with code Thursday and 15 mins on Friday. Now here's how it works, no code snippets I'm afraid cause I'm at home, so you'll have to live with my pseudo-variant, lol.
Really BIG thing for me to have done that. I know this method won't work in a lot of games, especially indoor ones. but since ours is in a bath, with no roof it's a good solution.
|
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
http://www.youtube.com/watch?v=sAyA3KvSe8Q Check this please. Video update on how we're doing |
|||
Lazarus![]() Member Posts: 1668 From: USA Registered: 06-06-2006 |
Haha. Nice video. ![]() What was that at the end where all of you vanished. |
|||
|
Brandon Member Posts: 594 From: Kansas City, Mo, USA Registered: 02-02-2004 |
Yeah, nice video and nice work ^^ ------------------ |
|||
|
Skynes Member Posts: 202 From: Belfast, N Ireland Registered: 01-18-2004 |
http://www.youtube.com/watch?v=z3mxUvoYMcw This was the first video we did, when we first did the disappearing trick. |