Maths help with my tools!

What I’m creating is Lightsabers, but for the life of me I cannot seem to get the crystal (the red beam) to stay in the same position as I resize it. I need the beam to only go up in one direction, whilst maintaining it’s position ontop of the part in the image below.

I want the beam to stay ontop of this part
image

But no matter what I have tried the beam always has a weird offset, for example;

This is my current code, no idea why I’m struggling with is but I am :frowning:
image

2 Likes

Just realized the gif I supplied wasn’t actually a gif, so here;
https://gyazo.com/a5837882bbe05efa4a9a5adef7118dc6

You may want to reference The HumanoidRootPart.CFrame.LookVector. That can help get your calculations much more accurately, becase I believe Vector3 is not relative to the position and direction the instance is facing. Also, maybe use a weld or weld constraint to keep it in place.

1 Like

Maybe not HumanoidRootPart.CFrame.LookVector, but any other way to get the correct location, and angle.

Yeah I’ve got a weld constraint already which keeps it from falling, I just can’t seem to work out the maths at all, really confusing.

Maybe you can do:

LightSaber.CFrame = LightSaberHandle.CFrame
LightSabe.Size = Vector3.new()
etc, etc

or something along those lines

I’ve tried CFrame too, but because of the constraint behavior it moves my entire character, I believe position is the only way forward with this, thanks for the help though!

Try not setting the position of the laser, and if that doesn’t work, try to rig it and animate the size instead.

Only reason I am setting the position is because if I change the size of the laser it origins on the center, unless there is a way I can prevent that? In which case I wouldn’t need to change the position at all

Solved it, thanks for all the tips!