So im trying to make a “lightning” effect where a part will be put in it will be randomly rotated by like 15 degrees. Then another part will be put in and it will go at the bottom of that part and rotate randomly but I still want the parts to be touching. Help would be appreciated!
You can get a part’s CFrame and get the lookVector, rightVector or upVector. To get the opposite of these (backwards, left and down vectors) you can get the negative values of them.
To get the actual position at the end of the part, you add the vector to the position of the part. Don’t really have the time at the moment to explain how you can draw a lightning path effect, but you can take a look at the code behind Stravant’s Lightning.
To get the position of a side
local Pos = (Part.CFrame * CFrame.new(0,0,Part.Size.Z/2)).p
Mess around with Part.Size/2 in each axis and making it negative, etc. to get different sides.
so this would be the bottom of the part?
That would be the back of the part if I remember right; making it negative would flip it to the front
and the bottom?
local Pos = (Part.CFrame * CFrame.new(0,-Part.Size.Y/2,0)).p
oh, thats what i was thinking.
thx tho!
No problem, happy to help.
Hi there!
This is also an option for anyone curious:
local cf = Part.CFrame
local sz = Part.Size
local pos = cf:PointToWorldSpace(
Vector3.new(
sz.X/2 --< Right >--
sz.Y/2 --< Top >--
sz.Z/2 --< Front >--
)
)
--//Make it '-' to flip the side
local pos = cf:PointToWorldSpace(
Vector3.new(
-sz.X/2 --< Left >--
-sz.Y/2 --< Bottom >--
-sz.Z/2 --< Back >--
)
)
Sorry for the revive, but I found this an easier method.