Jump to content

Poke in the right direction for firing a beam


Recommended Posts

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 ?! :rolleyes:

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 :)


Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites



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!


Link to comment
Share on other sites

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.

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.


  • Recently Browsing   0 members

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