Kreeba Posted July 17, 2017 Share Posted July 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 17, 2017 Share Posted July 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 17, 2017 Share Posted July 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
distraub Posted July 18, 2017 Share Posted July 18, 2017 is createInstance less expensive than clone? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 18, 2017 Share Posted July 18, 2017 Clearly. It reduces the draw call numbers a lot. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 18, 2017 Share Posted July 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
distraub Posted July 18, 2017 Share Posted July 18, 2017 Good to know, I think I had that backwards in my mind. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 18, 2017 Share Posted July 18, 2017 https://blog.raananweber.com/2015/09/03/scene-optimization-in-babylon-js/ all hail @RaananW Quote Link to comment Share on other sites More sharing options...
Kreeba Posted July 30, 2017 Author Share Posted July 30, 2017 Thanks. It works great. Marked as solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.