Jump to content
  • Advertisement
Sign in to follow this  
Aph3x

Vehicle shoots self

This topic is 5085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!