So I was thinking that my game would be better if you could see bullets come out of the gun. But I am having a bit of trouble doing that. You see I am wondering how you make a mesh animate forward. Well that might seem simple but it don’t think it is. I could just animate a ball or capsule moving in an X Y or Z direction, but the way I have the game set up is so that you can move the camera with your mouse and WASD keys. So just going in one of those directions is not enough. It has to go in the direction the gun is pointing. So how would I do this? I was thinking that the starting point would be like g.position
and then I have to figure out how to make it go forward from that position. The answer is probably right in front of me but I can’t seem to get it. Can you help me with this?
This is quite popular question!
You may have a look here - Create a simple machine gun - Questions - Babylon.js
I am not using version 3.3. In that topic they were
The version is not so important as the solutions inside the topic.
Anyway, you should decide first, do you want visible meshes as bullets or just the illusion of fire (which can be done with particles). As for every game feature you should decide, how much performance it can “eat” from the game.
In order to be sure that you hit the aim you need some function to process gun position, target coords and time of shooting. If you will make more efforts with the search, I am sure you’ll find some solutions since your question is really popular. I remember there was somewhere (in old docs?) quite good demo with Counter-Strike made with Babylon JS.
Here is another PG link which could be useful and just is funny itself - https://www.babylonjs-playground.com/#Z0QW21#9
SHOOT - right click
I also would recommend to search PG with “bullet” etc. - there are a lot of bullet examples!