Generating shapes?

Hi, I’m trying to design a “Hyper Drive” effect and have elected to use this style of shape to generate the beams etc. prior to moving to give a somewhat circular illusion around the ships.

I was wondering how I could use Code to generate the expanding circle shape from infront of the ship going outwards as displayed.

Currently my method works using random offsets along the RightVector and UpVector of the Star ship and I wish to change this to the circular effect shown.

Thanks in advance.

1 Like

EDIT

I found a snippet of code that works perfectly; however I need to adjust the angles to allow for the circular pattern to be directly infront of the Ship as opposed to on the ground itself -

for i = 0, math.pi*2, math.pi*2/reps do
	local a = Middle:clone()
	a.Position = orig+Vector3.new(rad*math.sin(i), 0, rad*math.cos(i))
	a.CFrame = CFrame.new(a.Position, orig)
	a.Anchored = true
	a.Parent = workspace
end

What I have:

What I need:

EDIT2://
I successfully managed to get it tilted in the right direction - Now it’s a matter of the Orientation:
image

The centre part is where the Ship will be located and will need to correspond with the orientation? How could I adjust this to allow for the circle to share the same orientation?

All you have to do from here is define a reference point (so the nose of your ship for example) and translate the entire structure to that point.

local origin = ship.Part.CFrame
for i = 0, math.pi*2, math.pi*2/reps do
	local a = Middle:clone()
	a.Position = Vector3.new(rad*math.sin(i), 0, rad*math.cos(i))
	a.CFrame = CFrame.new(a.Position, orig)
    a.CFrame = origin.CFrame * a.CFrame
	a.Anchored = true
	a.Parent = workspace
end

To rotate the structure you can either rotate your reference part or rotate the origin CFrame (by, for example, appending * CFrame.Angles(0, 0, math.pi/2) to the first line.

1 Like

Another possible way is to construct it into the a new origin and axis like a geometrical plane. You can do this by multiplying the

rad*math.sin(i)

With the UpVector of the ship to obtain the y axis change for that ship.

And

rad*math.cos(i))

With the RightVector to obtain the relative x axis change for that shift. Then you add these two vectors with the ships world position to get the new parts position on a plane defined by the UpVector and RightVector of the ship I believe.

writing on phone sorry

This works great a part from one part;
When cloning the other Parts to add to the Circle, they don’t share the same orientation?

The middle Part has a Y axis of -22.5 whereas the others cloned have the Y axis of -45?

If you used my code, I didn’t see one little thing:

a.CFrame = CFrame.new(a.Position, orig)

orig simply has to actually point toward the middle part, so

a.CFrame = CFrame.new(a.Position, Middle.Position)
1 Like

Hey, I used your code and it’s the:
a.CFrame = origin * a.CFrame

That works fine, Other than the cloned parts not sharing the same Orientation, however -
When I use
a.CFrame = CFrame.new(a.Position, Middle.Position)
I get this result where it doesn’t share the same rotations at all:

Note that the entire ship is currently on a Y Orientation Axis of 22.5 to test generation of the ‘Star’ parts.

You need to use both lines, first the CFrame.new call, then origin * a.CFrame, or, simplified to one line (since it originally was just a demonstrative solution):

local origin = ship.Part.CFrame
for i = 0, math.pi*2, math.pi*2/reps do
	local a = Middle:clone()
    a.CFrame = CFrame.new((origin.CFrame * CFrame.new(rad*math.sin(i), 0, rad*math.cos(i))).Position, Middle.Position)
	a.Anchored = true
	a.Parent = workspace
end
1 Like

I’ve DM’ed you as there’s been more issues. ._.