Game Development Community

Any ideas for implementing starship shields?

by Jack Stone · in Torque Game Engine Advanced · 02/18/2006 (10:50 am) · 4 replies

I have been delaying implementing this step in my project for a while, because I have a feeling its going to get tricky, but I think I have enough confidence to attempt it now.
What I need is, basically, shields for my starships, ala star trek.
The shields can be raised and lowered, and their strength indicates how much damage they will absorb from an incoming projectile.
So, if your shields are at 50%, and your hull is at 100%, and you're hit with a projectile that is capable of inflicting damage amounting to 20%, the shields will go down to 40% and your hull will go down to 90%.
In my game, I have/will have things mounted onto my hull, such as turrets, radio towers, etc, so that each object can be destroyed or disabled individually. This means that simply "blocking" the projectile wont work, I have to partially block it, but allow the hull to take some of the force from the impact.
Also, my ships own weapons should be able to fire through the shield while it is raised, without being affected. This means that a simple collision mesh wont work.

I need a collision mesh that can be deleted and created on the fly, that will allow projectiles through from one side but not the other, and that will allow a projectile to collide with it, but also inflict a percentage of that projectiles damage on the hull.

The collision mesh will also need to be almost invisible in normal operation, but when a projectile hits it, it should shimmer in the area where the projectile hits, but the whole shield should not shimmer. (Again, like star trek)

This seem even more complicated now that ive written it down, but my idea was this:
Make a standard collision box in max, in the shape of the shield. Break that mesh up into concave segments so it will actually work.
Then in game, find a way to create and delete this mesh at runtime. Perhaps if I make the mesh as a seperate object entirely? Then create that object at the world coordinates of the starship?
When a segment of the collision mesh has been hit, only that one shimmers, with some kind of shader.
Each segment would be linked to a function in script, that would calculate a hull damage percentage based on the strength of the shield and the strength of the projectile. This would then be applied to all objects mounted to the hull on that area of the ship by using basic script commands, for example:
If portshield is hit,
apply 20% damage to:
portturret1
portcountermeasures1
portturret2
portcountermeasures2

etc etc.

So basically, I need to access and control a collision box from script, and find a way to make a one way collision box that can be created and destroyed at runtime.
Then apply the shader whenever collision occurs.
I havent been able to find any resources for the collision box script control, or the one way collision. I havent looked into the shimmering shader yet.
Has anyone else doen anything like this? If I recal correctly there was a few space based games being made with torque, do any of them have shields?
Thanks,
JS

#1
03/30/2006 (3:24 pm)
It sounds like you're trying to make this more complicated than it really is.

for the projectiles striking the ship vs not striking the ship have the collision detection check the strength of the shield just prior to the missile impact. if the shield is not 0% the projectile detonates 1 unit before true impact. then you find the impact point the missile would have hit and cause a shader to apply a ripple affect to a ghost sphere around the ship or ship part you want to ripple. the ghost sphere is a 100% translucent layer around the model. the shader should be able to apply a glow or coloring effefct like you want on that external model. or if you wanted to be cheap on polys you could just spawn a disc at impact and have the disc play an animation on its surface of the ripple affect and just size it for the damage taken or whatever.
#2
03/31/2006 (1:38 am)
I definitely agree with Jesse. I would have one mesh exported for the starship (with a mount point at the absolute center) and another simple sphere shaped mesh large enough to encompass the starship exported as the shield. Then, simply mount/dismount the sphere to the ship as the shield goes up/down. The shield's texture should be translucent to still see the enclosed ship. You can also vary the shield texture's alpha level to based upon the shield strength. Also, using TSE, you can apply some very cool animated shader or glow effects to the shield.
#3
04/05/2006 (7:32 pm)
I agree with John and Jesse, no need to have a mesh that can deform, just use a mesh bigger than the spacecraft and vary the alpha based on strength of the field. Plus that eliminates having to worry about the shield allowing your missiles out and not allow missiles in. A nice shader effect would make it look neat too.
#4
04/11/2006 (3:11 pm)
Thanks guys, thats a great suggestion. Ive begun implementing it, and so far its going great. Ive got the transparent shield mesh mounting and dismounting via an in-game menu, and im working on modifying the collision code now. Ill leave the shader effects till last.
JS