Jump to content

(Advice) Using Animation for Bullets


Kreeba
 Share

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

Link to comment
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.

Link to comment
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.

Link to comment
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.
 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...