Collisions and explosions
Blitz3D Forums/Blitz3D Programming/Collisions and explosions
| ||
I am sure this has been asked 100 times before. I am using a TP system to move the character around the game. Whe it shoots the gun I am using types to generate the bullets which are a copy of a mesh. This works very well and I am pleased with the result. The problem occurs when I try to detect collisions. The collision works but then all goes pear shaped. What I want is for a) the bullet to stop moving an disappear b)An anmated texture to play on a sprite with the explosion at the point of the collision c)Once the animation has completed I want things to disappear and reset. All simple stuff you would think, but I get all sorts of issues detecting collisions, position of collisions. Getting the explosion to play completely. Any example code would be appreciated. Lee |
| ||
No code by now, but some ideas: right after updateworld and before Renderworld, check if the bullet collided. If it collided, store the location and angle of the collision and remove the bullet entirely, including its type etc. also use hideentity bullet freeentity bullet to make sure it's collision data is removed too before you delete it (some people reported related problems). Then use the Location (previously stored using collisionX etc.) to position a decal. Use Aligntovector and CollisionNx etc. to align the sprite to the surface if you want. You may have to turn it by 180 degrees and then move it slightly forward after using aligntovector. Then I'd suggest to use a homebrew Texture Animation system. You may create a type with a countdown variable, that will assign a frame-texture to the sprite until the countdown valiable is zero. If it became zero, remove the sprite and the type. |