Calculating laser energy
Hello, I am making realistic physics script for lasers. The problem is that I dont know the equations for this like calculating energy from all lasers pointing at same point. Object under attack should have script to calculate damage. Like if enough lasers hits same point on object it should explode based on energy calculations. I still don't know physics behind this so if someone could explaint it to me, I would be happy.
Answer by tylerdtrudeau · Mar 05, 2021 at 03:51 PM
Well this is a complex thing to do and you havent really given us much to go on in terms of code you have used or what approaches youve tried. But I will try to steer you in the right direction anyways. First of all is this a 2D or 3D game? It shouldnt matter too much but its just nice to know if we are working on all axis or just 2. As for the way to achieve the desired result, if in 3D i would probably do RayCast to see if lasers are pointing at target. If in 2D I would maybe just do a LineRenderer from the end of the laser and see if it intersects with the target. In both cases you can do a check on your target to see how many RayCasts or Linerenderers have hit/ intersected with it. Both of these concepts are covered extensively on youtube tutorials so I would recomend starting there. (its far too much info for me to try to teach you them through this forum). Keep us posted and cheers
It's 3D game, I figured out mechanism myself. I will just raycast on shoot and get hit gameobject. Everything I need is reference to equations/formulas to calculate laser energy at distance, laser operating power, frequency wavelength, ... so I can do it finally in unity