Arthuron Posted March 16, 2016 Share Posted March 16, 2016 Good day @all, I need a simple idea from you to create a laserbeam in babylon for the vehicles in my mini game. I want to get a front laserbeam and one in the back for firing on enemys but i dont have any idea to create one. create a ray/tube with the babylon.js particle system the right way or something like this, iam not sure an i need you ?! and my second question is, how i calculate simple the range/distance between my vehicle and another. Its ok if you say, simple mathematics, calculate correct the distance by the positions of you vehicles. Maybe you know a simpler or bether way to do that ?! Thanks for you time to read this, i hope you can help me cheers Quote Link to comment Share on other sites More sharing options...
jerome Posted March 16, 2016 Share Posted March 16, 2016 var distance = (mesh1.position.subtract(mesh2.position)).length(); JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Arthuron Posted March 16, 2016 Author Share Posted March 16, 2016 Ok thanks, thats helpes me ... but what is with my first question ... What is the best way to create a laserbeam in your opinion?! cheers Quote Link to comment Share on other sites More sharing options...
c75 Posted March 16, 2016 Share Posted March 16, 2016 @Arthuron can you give picture similar to waht you want? Quote Link to comment Share on other sites More sharing options...
Arthuron Posted March 16, 2016 Author Share Posted March 16, 2016 like this Quote Link to comment Share on other sites More sharing options...
jerome Posted March 16, 2016 Share Posted March 16, 2016 I have no current project on this, but I'm wondering about the same thing : what would the best way to do ? tubes ? billboarded ribbons ? sprites/particles ? I will check every attempt with interest JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 16, 2016 Share Posted March 16, 2016 Hi A! (and others) Good to see you again. Check out http://www.babylonjs-playground.com/#1WUQ1S#11 Wild! But the whole 1WUQ1S series of playgrounds... 0-12... is full of "light sabers". Some of the series has 's not found' problems... just add a comma 1 (,1) after the other numbers in the createCylinder calls. They are missing the height_subdivs parameter, which changed from optional, to mandatory. Maybe check this thread.... http://www.html5gamedevs.com/topic/9015-cylinder-between-two-points/ And I bet a playground search for 'vend' (the ending vector of the laser beam cylinder/tube)... will return a bunch of demos from people who have experimented-with cylinders/tubes between 2 points. "Vend' is likely the vector3 particle emitter for the particleSystem used at the impact point, when a "hit" is scored, too. Party on! Quote Link to comment Share on other sites More sharing options...
Arthuron Posted March 17, 2016 Author Share Posted March 17, 2016 Ok thats helped me. I added a cylinder between to points on a keypress event. This cylinder have a blue emissive color and a alpha value of 0.4 ... thanks again wingy for the help and the little poke in the right direction Cheers @all Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Arthuron Posted March 20, 2016 Author Share Posted March 20, 2016 Hmmm wingy (or any one else), you know how its possible to add particles inside of this cylinder there move from source (emitter) to the target? particle.emitter = ship1 //works good particle.target = ship2 //dosnt work Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 20, 2016 Share Posted March 20, 2016 Hey Arthuron, here is something i played around with while ago..never turned into into a real game..maybe I will some day http://p215008.mittwaldserver.info/space/ Maybe it helps or you want to sue anything from it, i was kinda happy with how it looked back in the days. just click the asteroids to shoot them. The spaceship rotation still had its problems..but the the laser itself is okay, i guess jerome and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 20, 2016 Share Posted March 20, 2016 Do this with BABYLON.Mesh.CreateLines() can be. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 22, 2016 Share Posted March 22, 2016 *nod* On 3/20/2016 at 7:05 AM, Arthuron said: particles inside of this cylinder there move from source (emitter) to the target That... is a challenge. Particles CAN BE directed in a straight line, appearing to travel along a cylinder "beam", but, it takes some time for the particles to travel distances, and I don't think it would look all that good. Another option might be to start the emitter with heavy flow, then upon 'fire', quickly move the emitter from source to target. But I think that would look more like a photon torpedo... than a phaser blast. At one time, I thought about a feature for particleSystems... that sprayed particles at every vertex of the 'fountain' mesh... each sprayer aiming the direction of the vertex's normal. (3D Max has this). I have not tried building that feature, yet. Imagine some particles spraying from every vertex along the cylinder between the source and target. Maybe even spraying toward the -normal... spraying towards the inside of the tube. Still, I don't think this will give you a nice effect. Maybe... the cylinder needs a fire or lava procedural texture, or some other shaderMaterial or post-process. Short laser blasts... no problems. The users don't get much time to study the beam. Long laser blasts... that's when you earn the "What a great laser beam" comments from the users. Love the Iceteroids demo, Iceman! Fun! 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.