Bullet Impact

Blitz3D Forums/Blitz3D Beginners Area/Bullet Impact

Xak(Posted 2008) [#1]
Greetings all!

I have a small problem that I can't seem to figure out how to fix. I'm developing a combat flight sim and I've gotten to the point of working on the weapons. I have it programmed so that when a bullet strikes the terrain, it triggers a small sprite animation of dust being kicked up, centered on the last known coordinate of the bullet prior to collision detection. My problem is that, due to the velocity of the bullets (25 units per loop,) the dust animation often ends up inside (below the surface) of my terrain model, and therefore, out of view. I am at a loss as to what I need to do to to ensure that the dust animation is always centered outside of the terrain geometry and inline with the bullet's path. Any ideas?

Thanks


markcw(Posted 2008) [#2]
I think what you need to do is linepick the y position of your terrain and then position the dust at this y position. Have a search for LinePick code.


Xak(Posted 2008) [#3]
I think what you need to do is linepick the y position of your terrain and then position the dust at this y position. Have a search for LinePick code.


If I understand you correctly, you are suggesting that I determine the altitude of my terrain model at the bullet's position and move my dust animation to that altitude. However, I can only imagine that working if my terrain were completely flat. My terrain model is quite mountainous, I'm afraid. By my thinking, that would cause the undesirable effect of placing the dust animation much higher than the bullet's point of impact if the bullet penetrated into the side of a mountain.

Thanks anyway.


Gabriel(Posted 2008) [#4]
I think what MarkCW means is to Linepick from the last known position to the position the bullet will be in after being moved and if it collides, use the collision point as the place to put the sprite.


Matty(Posted 2008) [#5]
Use the collisionX,collisionY,collisionZ commands as these will give you the exact position in world space of the collision between bullet and ground.

For ColID=1 to CountCollisions(BulletEntity) ;bulletentity would be defined elsewhere, I think you know what I mean here
     ColEntity=CollisionEntity(BulletEntity,ColID)
     If GetEntityType(ColEntity)=CollisionType_Scene then ;CollisionType Scene is a constant declared earlier for your ground entity type
          CreateDustCloud(CollisionX(BulletEntity,ColID),CollisionY(BulletEntity,ColID),CollisionZ(BulletEntity,ColID))
;CreateDustCloud would be a function that takes X,Y,Z coordinates and creates a dust cloud there.  
    endif 
next





The above code is just a simple example of how you might go about it, there are many ways to skin a cat as it were...


Xak(Posted 2008) [#6]
Thank you, Matty. That was extremely helpful. :)