Kreeba

(Advice) Using Animation for Bullets

Recommended Posts

Hello everyone,

I am making a spaceship game. When a player ship shoots at another ship I am already calculating if it is a hit/miss. I am not going to use any collisions, its just a calculation. Given this, I would like to a bullet tracer (probably a polygon). It will be going very fast, so its more of a visual indication rather than any physics involved.

The bullet will just move from the gun vec3 to the target vec3.

Rather than building a system to track each bullet type and its position and progression, I would I would use the inbuilt animation system as it seems like a good 'fire and forget' system for this type of thing.

Is this a wise decision, is it an expensive (CPU) system if there are many animations present? I also saw I can pickup on an end-frame event. Is it wise to destroy the mesh and attached animation when it gets to the end-frame?

 

Thanks

Share this post


Link to post
Share on other sites

This is a pretty good option.

One advise: Reuse meshes for your bullets. Create a pull of pre-created bullets by creating one master and multiple instances (with mesh.createInstance). Then mark all of them as disabled with mesh.setEnabled(false). WHen you want to fire a bullet, take one in your pull, launch the animation and onAnimationEnd you can disable the bullet and store it in the pull again.

Share this post


Link to post
Share on other sites

given the speed of bullets, I would use Delta method but instead of a "bullet" mesh use a really simple cylinder and a scale animation that "stretches" the cylinder in its local y or height direction.  Then script up a custom shader for them to make them look more like tracers.  Just a small bullet flying wont have the same effect.

Share this post


Link to post
Share on other sites

yes, but there are restrictions.
 With an instance you can not assign a different material and do not have as much control over making it different then the original, but you can change its position and scaling which is what your interested in.

A clone is a whole new unique geometry with its own draw calls.
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.