Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Looking for a sample/demo/tute  (Read 539 times)
Arakiel
Community Member
*
Posts: 26


« on: June 10, 2008, 09:35:54 PM »

Evening.  My "fly around space" project has gotten to the point now where I would like to start shooting stuff Smiley

The problem is, I can't seem to find anything in the way of TV6.5 samples for collision detection.  Does anyone know of/have a simple collision detection sample to get me started in the right direction?  One geared towards shooting bullets/lasers would be even better but I'll take anything I can get and extrapolate at this point.  I simply have no clue how to start.

Thank in advance!
Logged
newborn
Customers
Community Member
*****
Posts: 2417


WWW
« Reply #1 on: June 11, 2008, 06:22:02 AM »

you basically have to trace a line between the start point (your gun) to the end point. the end point can be tricky to find, depending on the type of game you are making (3rd person, 1rst person, 2D scroller, etc).

a very easy way to get around that is to create a mesh projectile, place it where your gun is, set the same rotation values of your gun and then use meshProjectile.MoveRelative(maxDistanceYourProjectileCanGo, 0, 0) and use thie new position as your end point

when you have your 2 points (called vectors), you use collision = tvscene.advancedcollision to see what intersects in between (if collision.isimpact). from there, you can get the mesh or actor or landscape ID and start having fun Smiley
Logged

Arakiel
Community Member
*
Posts: 26


« Reply #2 on: June 11, 2008, 07:18:12 AM »

Thanks newborn that helps quite a bit.

If you don't mind I would like to ask a related question that hopefully you won't think is too noobish heh.

While the technique you describe works well for "instant shots" such as bullets in an fps which hit their target immediately, for slower projectiles such as missiles or "lasers" in traditional space combat games I think it needs an adjustment.  If the projectile doesn't reach it's target in the frame in which it is fired then the source or "gun" could and likely would, move in between causing the ray thats drawn to be off and potentially giving a false positive.

What I think needs to happen in those cases, and please correct me here, is that the projectile itself becomes both start AND end point.  i.e.

1. Get projectile position as startpoint
2. Move projectile
3. Get projectile position as endpoint
4. Detect for collisions along those 2 points
5. Do something cool with that knowledge

Do I have that right?  Again I apologize if that's a really noobish question but this is all kinda new to me.

-Arakiel
Logged
sciophyte
Customers
Community Member
*****
Posts: 207


« Reply #3 on: June 11, 2008, 12:04:16 PM »

the idea behind a slower projectile is to test how far it is moving within one iteration of your loop.  you calculate the distance your projectile should have moved within the frame based on the velocity of the projectile and then use that as your end point, then you test the collision before your actually decide to move it.
Logged
Arakiel
Community Member
*
Posts: 26


« Reply #4 on: June 11, 2008, 12:57:38 PM »

Ahh true, good point.  Why waste time rendering something that's going to blow up anyway.
Logged
newborn
Customers
Community Member
*****
Posts: 2417


WWW
« Reply #5 on: June 11, 2008, 03:21:04 PM »

Ahh true, good point.  Why waste time rendering something that's going to blow up anyway.

Well it depends on the stuff you are shooting. the only real experience I have with projectiles is with paint ball and I know that a paintball bullet goes approx 250ft per sec so a real bullet must go at least 3-4 times faster than that; it's darn fast.

Now if you want to go with slow projectiles, it's the same story as I first mentionned: moverelative will simply shorter (50 instead of 1000).

Also:

1. Get projectile position as startpoint
2. Move projectile
3. Get projectile position as endpoint
4. Detect for collisions along those 2 points
5. Do something cool with that knowledge


At #5, you can do something really cool there. for instance, you can do a blood splatter, play a sound effect, some explosion or what not. If it is for a projectile, why dont you run an additional ray tracing from that collision position to have that bullet passing through multiple objects?
Logged

Arakiel
Community Member
*
Posts: 26


« Reply #6 on: June 11, 2008, 03:45:59 PM »

Well I'm shooting "lasers" but exact realism isn't really what I am shooting (heh) for.  I'm also not using newtonian physics for my movement in space for the same reason.

Quote
At #5, you can do something really cool there. for instance, you can do a blood splatter, play a sound effect, some explosion or what not. If it is for a projectile, why dont you run an additional ray tracing from that collision position to have that bullet passing through multiple objects?

Heh, I would love to, but first I have to get the code to agree that my enemy ship is collide-able Smiley  right now my code and I are having a difference of opinion LOL.
Logged
Hypnotron
Customers
Community Member
*****
Posts: 792


« Reply #7 on: June 29, 2008, 08:10:36 AM »

you could do something where the less damage the bullet inflicted, the greater the chance it passed through the target and can still strike something else. 
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks