Game Development Community

Explosions not being rendered.

by Joshua Jewell · in Torque Game Engine · 02/02/2007 (5:00 pm) · 3 replies

I am having a problem with Explosions. For some reason not all of the projectiles that are fired generate an explosion. I went into the code a tad and discovered that the Explosion objects are being created, but renderObject is not always being called. Is anyone familiar with this problem? I figured I would check for an answer in the forums before I dig any deeper into the game engine.

#1
02/03/2007 (7:10 am)
Ok, so when I reduced the projectile speed from 600 m/s to 6 m/s the problem disappeared. I am thinking that if the projectile is created and destroyed to quickly it may not have enough time to be ghosted to the clients. The fact that this problem is occurring when I am the server and client is a bit scary. One way to fix this may be to ghost the explosion itself.

Has anyone else had experience with this?

Here is a list of some things I have noted:

1) The projectile is being properly ghosted, even when the explosion does not render.

2) The Explosion is always created. This has to be taking place on the client side since Explosions do not exist on the server side.

3) The projectile is not being deleted before it explodes on the client.

4) Reducing the projectiles speed results in more explosion being rendered.

I am starting to think the problem may lie where ever the engine decides to do its rendering.
#2
02/03/2007 (8:14 am)
Take it easy, people will see your thread even if you do not bump it.

Basically, the projectile's travel is simulated on both client and server. It checks for collision by casting a ray in the direction of travel to the next position based on the current speed.
Sometimes the server thinks the projectile has hit something while the client does not, and the server does the onCollision call (damage, bla bla) and then propogates the ghost change to the client which deletes the projectile before it has exploded.

There's a whole slew of different ways to solve this, some better and some worse. Try manually calling explode when the projectile is being deleted (not in the deconstructor).
#3
02/05/2007 (4:10 pm)
Well I have not been able to figure out exactly what is causing this problem and I feel a bit defeated. However, I have figured out how to stop the problem from happening. My explosions were not always being rendered when the lifetime of the explosion was 50ms. When I increased the lifetime to 100ms no explosions were missed, even when the projectile speed was 6000 m/s.

As I have stated above the explosion is always created even when it is not rendered. What is off is that the sound and decal of the explosion always worked.

Hopefully this post will help anyone that may come across the same problem. If I am the only one to ever have this problem then maybe I am just going crazy!

*Edit below here

Ok I have finally figured out what was causing my problem. On the client SceneGraph keeps track of all the objects that are ghosted and decides which ones to render. SceneObject::renderObject() is the method that is responsible for rendering the objects. What was happening with the Explosion is that it was being added to and removed from the SceneGraph before the next renderObject call was made. Here is some documentation on the SceneGraph:

http://www.garagegames.com/docs/tge/general/ch06s10.php