Make a cylinder tween position on a local axis

I want to make a laser extending from a little cylinder to a longer one, something like what I represented below:

2D


3D


If you get what I am saying, I’m trying to replicate something like how the editor scales cylinders:



How would I do this on a local axis?

Your best bet is utilizing a raycast

the raycast should shoot from the flat heads of the cylnder to determine the end size or from the red part surface?

depending how you do it you would use the the result of the raycast(s) to determine the xy (or xz rather?) size of the cyl

i am not able to assist any further at the moment as i am not at my main comp perhaps someone else can assist further

Aren’t raycasts a bit performance intensive if I use them over 96 times in around 3 seconds? Plus since the cylinder is a mesh with an empty inside, wouldn’t the raycast not detect it?

Using some vector math you can make that easily

local lenght = (part1.Position - part2.Position).magnitude -- the distance between the parts
local middle = (part1.Position + part2.Position)/2 -- middle point

local Goals = {
   Position = middle
   Size = Vector3.new(lenght/2,radius,radius) 
}

local Tween = TweenService:Create(Laser,Tweeninfo.new("[[ fill this the way you like]]"),Goals)

part2.Position can be substituted with ray.Position

1 Like