Marcousik Posted September 20, 2017 Share Posted September 20, 2017 Hey people, Does anybody has an idea how to cast a laser ray ingame, (without getting out of memory ) ? "simple" thing like this, something you see in so much games, well, how to make this with Leadwerks ? thx Quote Link to comment Share on other sites More sharing options...
gamecreator Posted September 20, 2017 Share Posted September 20, 2017 You can create a 1-unit long cylinder with its origin/pivot on one end. Position it to the muzzle. Then Point it at a target and scale it out with the distance between the two points. That's how I did it in one of my tournament attempts. Edit: found the code at home. Looks like I already had the laser parented to the robot. The rest just looked like this (after finding the closest rock in an array of rocks): Vec3 rp = rock[closestrockindex].model->GetPosition(true); player.laserblue->Point(rp.x, rp.y+0.8, rp.z, 2, 1, 0); player.laserblue->SetScale(0.4, 0.4, player.laserred->GetDistance(rock[closestrockindex].model) / 10); 1 Quote Link to comment Share on other sites More sharing options...
Marcousik Posted September 20, 2017 Author Share Posted September 20, 2017 That's nice thx Quote Link to comment Share on other sites More sharing options...
Josh Posted September 20, 2017 Share Posted September 20, 2017 I would use two sprites, one for the beam and one for the end point. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted September 20, 2017 Share Posted September 20, 2017 8 hours ago, Josh said: I would use two sprites, one for the beam and one for the end point. This is another set of functions that could use at least a single example in the docs. And a laser between a box and a sphere would probably be the perfect example. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted September 20, 2017 Author Share Posted September 20, 2017 So yes using sprites allow more "lighting" effect around the lazer. And if I understood this right, then you have to place the sprite in the middle of the way between startpoint and endpoint, then align it in th e right direction, and finally set the distance as size. For this Jen you are using the pythagorean theorem in 3D am I right ? Maybe using DistanceToPoint() may be good too https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Plane_DistanceToPoint Quote Link to comment Share on other sites More sharing options...
Einlander Posted September 21, 2017 Share Posted September 21, 2017 https://www.leadwerks.com/community/topic/15771-beam-class/ Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted September 21, 2017 Share Posted September 21, 2017 There is a laser.lua script in the following thread which might help. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted September 21, 2017 Author Share Posted September 21, 2017 thx. This should be uploaded in the workshop ! Edit here are the links: https://www.leadwerks.com/community/topic/15771-beam-class/ https://www.leadwerks.com/community/topic/13275-help-with-trip-wires/?tab=comments#comment-93679 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.