Jump to content

Lazer Ray?


Marcousik
 Share

Recommended Posts

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

 

  • Upvote 1
Link to comment
Share on other sites

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

 

 

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.

Guest
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.

 Share

×
×
  • Create New...