Hello, I am having a trouble to rotate the sphere created by the planes it is made of.
The sphere starts creating under the player and ends above the player, but I want it to start creating behind the player and end in front of the player.
I would love any help I can get as I am not that good with math to understand how to turn it by 90 degrees.
local function createPlaneLine(center)
local angleStep = math.pi / numPlanes
for i = 1, numPlanes do
local theta = math.pi * (i / numPlanes - 0.5)
for j = 1, numPlanes do
local phi = 2 * math.pi * (j / numPlanes)
local x = radius * math.cos(theta) * math.cos(phi)
local y = radius * math.sin(theta)
local z = radius * math.cos(theta) * math.sin(phi)
local rotatedX = z
local rotatedZ = -x
local position = center.Position + Vector3.new(rotatedX, y, rotatedZ)
local directionToPlayer = (center.Position - position).unit
createPlane(position, directionToPlayer)
end
wait(0.1)
end
end
It still doesn’t work right, it now spawns it rotated by 90 degrees but it always spawns on the same orientation. I would love if it would always spawn behind the player, any solution for that?
The code looks like this right now, tell me if you want the complete code.
local function createPlaneLine(center)
local angleStep = math.pi / numPlanes
for i = 1, numPlanes do
local theta = math.pi * (i / numPlanes - 0.5)
for j = 1, numPlanes do
local phi = 2 * math.pi * (j / numPlanes)
local x = radius * math.cos(theta) * math.cos(phi)
local y = radius * math.sin(theta)
local z = radius * math.cos(theta) * math.sin(phi)
local rotatedX = z
local rotatedZ = -x
local position = center.Position + CFrame.fromOrientation(-90,math.pi/1.5,0):VectorToWorldSpace(Vector3.new(rotatedX, y, rotatedZ))
local directionToPlayer = (center.Position - position).unit
createPlane(position, directionToPlayer)
end
wait(0.1)
end
end