Vehicle shoots self

Started by
21 comments, last by BlackMoons 19 years, 7 months ago
Hi all, Has anyone had to deal with objects (vehicles) that launch projectiles which can hit the launching vehicle? I can see a few approaches: 1. Wait a short time period and then 'arm' the projectile. 2. Wait til projectile has travelled a bit then arm it. 3. Wait until the projectile is not colliding with anything then arm it. I want it so that its possible for some vehicles to be able to shoot themselves in certain situations, so can't exclude collisions with the launching vehicle totally. Anyone here dealt with this before, and how well did your approach work?
Advertisement
4. Do not allow the projectile to collide with the launch vehicle if its velocity is away from the direction of the launch vehicle.
5) do not allow collision between projectile and parent, where the parent is the launching vehicle.

My problem here is I keep thinking about a tank, which is shooting itself by aiming down. Technically, the projectile is aimed "away" from the tank...but it still hits it. In this situation, I would simply have the turret and the tank be different collision areas (turret is parent, so collision with body is okay!), but that is far too specific and not wide enough an answer to be implemented in all your vehicle needs.

What kind of launching vehicles are you using? 2d or 3d?
You could also set a timer on when it can hit the shooter, you could check for collision outside a physical radius, you could create the projectile outside of the vehicles collision range, or you could code in those "special situations".. such as bouncing a wall arms the projectile to be able to damage the shooting vehicle. There are probably a lot more ways than those listed by the three posters so far.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
I previously used the approach that the vehicle cannot be hit by a projectile moving away from it.

This is straightforward and doesn't require any additional state to be kept. It's the way to go.

Mark
Just shoot the missile from a short distance in front of the vehicle (so it does not collide on the fist step). The velocity of the projectile should be missile.speed+vehicle.speed (because "at rest" the missile already has the speed of the vehicle carrying it).

Normally you shouldn't have to add anything else to your code.

Since the missile will go faster than the vehicle, the only ways the vehicle will be harmed by the missile are:
- missile exploding too close,
- vehicle getting in the trajectory of the missile (if it's a homing missile, or if the missile slows down and the vehicle can catch it).
Because if it shoots up at an angle, it could still be facing "away", but legitimatly hit the vehicle.

Why not use some physics, and add the vehicle's velocity to thwe projectile's. Realistic, and when the vehicle is moving, it can't easily hit the projectile. And if it does, it was probably intentional.
if(this.post == SATISFYING){money.send(1.00,&HemoGloben);return thanks;}
if the projectile doesn't hit tanks with the same direction as itself: how are you going to fix chases? You can't chase someone if the projectile just goes trough the target. Plus players might just start "running away" when a projectile is coming, to avoid it, and then turn back.
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
The thing I see is to take the tank out of the canadate list for objects that take damage.

yeah, it sucks to be playing an online game with slow weapons that do lots of dammage and have killer lag. Eg. outrunning your own missile, only to be blasted by it.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Vehicles are 3d. The main need is when aircraft launch missiles and their damn wings can get in the way if e.g. rolling.
I have a big vehicle with a turret that can shoot its own extremities though.

> falcone: I think that's cases 1 & 2, but I want the projectiles to spawn 'in-place' exactly where they are stored under the wings.

> sneftel/markr: no hit if velocity is moving away.
hmm nice sneaky idea, but won't work for the turret self-hittage.

> visage: yes, I want as you describe: e.g. tanks to be able to shoot their extremities.
Hmm spose I'll have to look into prodding my collision stuff for special cases :-/

I'm using proper velocity physics (setting projectile velocity to vehicle velocity on launch).

This topic is closed to new replies.

Advertisement