• Register a free account to view all forum content. Click here to create your own account.

Help with something

BornToGolf

Well-known Member
Joined
Apr 17, 2018
Messages
3,186
Ratings
251 1
Roblox
Born2Golf_OniPad
Discord
Deleted
So I have a brick that I want to act as a planet (when you walk off one side of it, you move on to the next side) but it only effects this brick. You can basically just go around and around the brick but I only want it to effect this brick.
 
Joined
Jun 4, 2018
Messages
101
Ratings
6
Roblox
proclet
Joined
Feb 25, 2018
Messages
217
Ratings
66
Roblox
CallMeKY
Discord
CallMeKY#5012
It would be easier to make the planet a sphere and rotate that as the player tries to move. To move the character around a cube you'd definitely need some camera manipulation, and to make the character position horizontal or flipped upside-down you might need a custom control script where you CFrame the character relative to their position around the cube as they "walk". If you use multiple planets, maybe you could use GetMass to determine which planet you're pulled to, and float / fly if you're out of range from everything. Maybe the way I generate satellites in this could help you figure out how to control the character, but it'll probably be quite a bit different if you have flat sides and you wouldn't be using tweens.
Code:
local Amount = 5        -- amount of satellites to generate
local Speed = 1000        -- rotation speed
local TweenTime = 1        -- base tween time. might be modified later depending on speed

local TweenService = game:GetService('TweenService')
local Theta = math.pi * 2 / Amount

-- part generation
local Model = Instance.new('Model', workspace)
local Base = Instance.new('Part')
Base.Shape = Enum.PartType.Cylinder
Base.Size = Vector3.new(10, 10, 10)
Base.Color = Color3.fromRGB(0, 255, 0)
Base.BottomSurface = Enum.SurfaceType.Smooth
Base.TopSurface = Enum.SurfaceType.Smooth
Base.CanCollide = false
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, -20) * CFrame.Angles(0, math.rad(90), 0)
Base.RotVelocity = Vector3.new(0, 0, 50)
Model.PrimaryPart = Base

local Satellite = Instance.new('Part')
Satellite.Shape = Enum.PartType.Block
Satellite.Size = Vector3.new(10, 5, 5)
Satellite.BottomSurface = Enum.SurfaceType.Smooth
Satellite.TopSurface = Enum.SurfaceType.Smooth
Satellite.CanCollide = false

-- generate satellites around the base, pointing at the center
for i = 1, Amount do
    local Angle = Theta * i
    local Size = Base.Size.X
    local X = Size * math.cos(Angle)
    local Y = Size * math.sin(Angle)
    local Z = Base.Position.Z
    local newSatellite = Satellite:Clone()
    newSatellite.Color = Color3.fromRGB(math.random(0, 255), 0, math.random(0, 255))
    newSatellite.Parent = Model
    newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0)
    local newWeld = Instance.new('WeldConstraint',Base)
    newWeld.Part0 = Base
    newWeld.Part1 = newSatellite
end

Base.Parent = Model

-- clamp speed. if speed is too high, adjust tween time
Speed = math.clamp(Speed, 100, 10000)
if Speed > 1999 then
    TweenTime = TweenTime / (((Speed - 1999) / 1999) + 1)
    Speed = 1999
end

-- generate tween info and a dummy cframe value to be used for tweens
local Tween_Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local DummyCFrame = Instance.new('CFrameValue')
DummyCFrame.Value = Model:GetPrimaryPartCFrame()
DummyCFrame:GetPropertyChangedSignal('Value'):Connect(function()
    Model:SetPrimaryPartCFrame(DummyCFrame.Value)
end)

-- do the actual tween on a loop, adjusting the tween for its current position
while true do
    local TweenCrusher = TweenService:Create(DummyCFrame, Tween_Info, {Value = DummyCFrame.Value * CFrame.Angles(math.pi / (1000 / (Speed / 2)), 0, 0)})
    TweenCrusher:Play()
    TweenCrusher.Completed:Wait()
end
 

BornToGolf

Well-known Member
Joined
Apr 17, 2018
Messages
3,186
Ratings
251 1
Roblox
Born2Golf_OniPad
Discord
Deleted
It would be easier to make the planet a sphere and rotate that as the player tries to move. To move the character around a cube you'd definitely need some camera manipulation, and to make the character position horizontal or flipped upside-down you might need a custom control script where you CFrame the character relative to their position around the cube as they "walk". If you use multiple planets, maybe you could use GetMass to determine which planet you're pulled to, and float / fly if you're out of range from everything. Maybe the way I generate satellites in this could help you figure out how to control the character, but it'll probably be quite a bit different if you have flat sides and you wouldn't be using tweens.
Code:
local Amount = 5        -- amount of satellites to generate
local Speed = 1000        -- rotation speed
local TweenTime = 1        -- base tween time. might be modified later depending on speed

local TweenService = game:GetService('TweenService')
local Theta = math.pi * 2 / Amount

-- part generation
local Model = Instance.new('Model', workspace)
local Base = Instance.new('Part')
Base.Shape = Enum.PartType.Cylinder
Base.Size = Vector3.new(10, 10, 10)
Base.Color = Color3.fromRGB(0, 255, 0)
Base.BottomSurface = Enum.SurfaceType.Smooth
Base.TopSurface = Enum.SurfaceType.Smooth
Base.CanCollide = false
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, -20) * CFrame.Angles(0, math.rad(90), 0)
Base.RotVelocity = Vector3.new(0, 0, 50)
Model.PrimaryPart = Base

local Satellite = Instance.new('Part')
Satellite.Shape = Enum.PartType.Block
Satellite.Size = Vector3.new(10, 5, 5)
Satellite.BottomSurface = Enum.SurfaceType.Smooth
Satellite.TopSurface = Enum.SurfaceType.Smooth
Satellite.CanCollide = false

-- generate satellites around the base, pointing at the center
for i = 1, Amount do
    local Angle = Theta * i
    local Size = Base.Size.X
    local X = Size * math.cos(Angle)
    local Y = Size * math.sin(Angle)
    local Z = Base.Position.Z
    local newSatellite = Satellite:Clone()
    newSatellite.Color = Color3.fromRGB(math.random(0, 255), 0, math.random(0, 255))
    newSatellite.Parent = Model
    newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0)
    local newWeld = Instance.new('WeldConstraint',Base)
    newWeld.Part0 = Base
    newWeld.Part1 = newSatellite
end

Base.Parent = Model

-- clamp speed. if speed is too high, adjust tween time
Speed = math.clamp(Speed, 100, 10000)
if Speed > 1999 then
    TweenTime = TweenTime / (((Speed - 1999) / 1999) + 1)
    Speed = 1999
end

-- generate tween info and a dummy cframe value to be used for tweens
local Tween_Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local DummyCFrame = Instance.new('CFrameValue')
DummyCFrame.Value = Model:GetPrimaryPartCFrame()
DummyCFrame:GetPropertyChangedSignal('Value'):Connect(function()
    Model:SetPrimaryPartCFrame(DummyCFrame.Value)
end)

-- do the actual tween on a loop, adjusting the tween for its current position
while true do
    local TweenCrusher = TweenService:Create(DummyCFrame, Tween_Info, {Value = DummyCFrame.Value * CFrame.Angles(math.pi / (1000 / (Speed / 2)), 0, 0)})
    TweenCrusher:Play()
    TweenCrusher.Completed:Wait()
end
So that could work to make the player go all around the brick?
 
Joined
Feb 25, 2018
Messages
217
Ratings
66
Roblox
CallMeKY
Discord
CallMeKY#5012
newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0) I think would be the most helpful part, you'd probably have to play around with the angle a bit, but this is what positions the satellite and rotates it to face the center. If you got the angle right and worked in which face you were supposed to be perpendicular to, either running it with Stepped or updating the angle after the character hits a certain point might work. I could try some stuff out later, I've never done something like this so it could be fun lol.
 

BornToGolf

Well-known Member
Joined
Apr 17, 2018
Messages
3,186
Ratings
251 1
Roblox
Born2Golf_OniPad
Discord
Deleted
newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0) I think would be the most helpful part, you'd probably have to play around with the angle a bit, but this is what positions the satellite and rotates it to face the center. If you got the angle right and worked in which face you were supposed to be perpendicular to, either running it with Stepped or updating the angle after the character hits a certain point might work. I could try some stuff out later, I've never done something like this so it could be fun lol.
Thanks. My idea is there is a 100x100x100 that the players can go on all 6 sides of, making a very interesting FPS match.
 
Joined
Jun 4, 2018
Messages
101
Ratings
6
Roblox
proclet
It would be easier to make the planet a sphere and rotate that as the player tries to move. To move the character around a cube you'd definitely need some camera manipulation, and to make the character position horizontal or flipped upside-down you might need a custom control script where you CFrame the character relative to their position around the cube as they "walk". If you use multiple planets, maybe you could use GetMass to determine which planet you're pulled to, and float / fly if you're out of range from everything. Maybe the way I generate satellites in this could help you figure out how to control the character, but it'll probably be quite a bit different if you have flat sides and you wouldn't be using tweens.
Code:
local Amount = 5        -- amount of satellites to generate
local Speed = 1000        -- rotation speed
local TweenTime = 1        -- base tween time. might be modified later depending on speed

local TweenService = game:GetService('TweenService')
local Theta = math.pi * 2 / Amount

-- part generation
local Model = Instance.new('Model', workspace)
local Base = Instance.new('Part')
Base.Shape = Enum.PartType.Cylinder
Base.Size = Vector3.new(10, 10, 10)
Base.Color = Color3.fromRGB(0, 255, 0)
Base.BottomSurface = Enum.SurfaceType.Smooth
Base.TopSurface = Enum.SurfaceType.Smooth
Base.CanCollide = false
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, -20) * CFrame.Angles(0, math.rad(90), 0)
Base.RotVelocity = Vector3.new(0, 0, 50)
Model.PrimaryPart = Base

local Satellite = Instance.new('Part')
Satellite.Shape = Enum.PartType.Block
Satellite.Size = Vector3.new(10, 5, 5)
Satellite.BottomSurface = Enum.SurfaceType.Smooth
Satellite.TopSurface = Enum.SurfaceType.Smooth
Satellite.CanCollide = false

-- generate satellites around the base, pointing at the center
for i = 1, Amount do
    local Angle = Theta * i
    local Size = Base.Size.X
    local X = Size * math.cos(Angle)
    local Y = Size * math.sin(Angle)
    local Z = Base.Position.Z
    local newSatellite = Satellite:Clone()
    newSatellite.Color = Color3.fromRGB(math.random(0, 255), 0, math.random(0, 255))
    newSatellite.Parent = Model
    newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0)
    local newWeld = Instance.new('WeldConstraint',Base)
    newWeld.Part0 = Base
    newWeld.Part1 = newSatellite
end

Base.Parent = Model

-- clamp speed. if speed is too high, adjust tween time
Speed = math.clamp(Speed, 100, 10000)
if Speed > 1999 then
    TweenTime = TweenTime / (((Speed - 1999) / 1999) + 1)
    Speed = 1999
end

-- generate tween info and a dummy cframe value to be used for tweens
local Tween_Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local DummyCFrame = Instance.new('CFrameValue')
DummyCFrame.Value = Model:GetPrimaryPartCFrame()
DummyCFrame:GetPropertyChangedSignal('Value'):Connect(function()
    Model:SetPrimaryPartCFrame(DummyCFrame.Value)
end)

-- do the actual tween on a loop, adjusting the tween for its current position
while true do
    local TweenCrusher = TweenService:Create(DummyCFrame, Tween_Info, {Value = DummyCFrame.Value * CFrame.Angles(math.pi / (1000 / (Speed / 2)), 0, 0)})
    TweenCrusher:Play()
    TweenCrusher.Completed:Wait()
end
That's interesting. But consider that the "planet" is not empty, there are a lot of items scattered all around. Some of them achored, some of them not. Imagine trying to rotate them all, at the same time, as the planet is rotating. Would be a nightmare lag.
 

BornToGolf

Well-known Member
Joined
Apr 17, 2018
Messages
3,186
Ratings
251 1
Roblox
Born2Golf_OniPad
Discord
Deleted
It would be easier to make the planet a sphere and rotate that as the player tries to move. To move the character around a cube you'd definitely need some camera manipulation, and to make the character position horizontal or flipped upside-down you might need a custom control script where you CFrame the character relative to their position around the cube as they "walk". If you use multiple planets, maybe you could use GetMass to determine which planet you're pulled to, and float / fly if you're out of range from everything. Maybe the way I generate satellites in this could help you figure out how to control the character, but it'll probably be quite a bit different if you have flat sides and you wouldn't be using tweens.
Code:
local Amount = 5        -- amount of satellites to generate
local Speed = 1000        -- rotation speed
local TweenTime = 1        -- base tween time. might be modified later depending on speed

local TweenService = game:GetService('TweenService')
local Theta = math.pi * 2 / Amount

-- part generation
local Model = Instance.new('Model', workspace)
local Base = Instance.new('Part')
Base.Shape = Enum.PartType.Cylinder
Base.Size = Vector3.new(10, 10, 10)
Base.Color = Color3.fromRGB(0, 255, 0)
Base.BottomSurface = Enum.SurfaceType.Smooth
Base.TopSurface = Enum.SurfaceType.Smooth
Base.CanCollide = false
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, -20) * CFrame.Angles(0, math.rad(90), 0)
Base.RotVelocity = Vector3.new(0, 0, 50)
Model.PrimaryPart = Base

local Satellite = Instance.new('Part')
Satellite.Shape = Enum.PartType.Block
Satellite.Size = Vector3.new(10, 5, 5)
Satellite.BottomSurface = Enum.SurfaceType.Smooth
Satellite.TopSurface = Enum.SurfaceType.Smooth
Satellite.CanCollide = false

-- generate satellites around the base, pointing at the center
for i = 1, Amount do
    local Angle = Theta * i
    local Size = Base.Size.X
    local X = Size * math.cos(Angle)
    local Y = Size * math.sin(Angle)
    local Z = Base.Position.Z
    local newSatellite = Satellite:Clone()
    newSatellite.Color = Color3.fromRGB(math.random(0, 255), 0, math.random(0, 255))
    newSatellite.Parent = Model
    newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0)
    local newWeld = Instance.new('WeldConstraint',Base)
    newWeld.Part0 = Base
    newWeld.Part1 = newSatellite
end

Base.Parent = Model

-- clamp speed. if speed is too high, adjust tween time
Speed = math.clamp(Speed, 100, 10000)
if Speed > 1999 then
    TweenTime = TweenTime / (((Speed - 1999) / 1999) + 1)
    Speed = 1999
end

-- generate tween info and a dummy cframe value to be used for tweens
local Tween_Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local DummyCFrame = Instance.new('CFrameValue')
DummyCFrame.Value = Model:GetPrimaryPartCFrame()
DummyCFrame:GetPropertyChangedSignal('Value'):Connect(function()
    Model:SetPrimaryPartCFrame(DummyCFrame.Value)
end)

-- do the actual tween on a loop, adjusting the tween for its current position
while true do
    local TweenCrusher = TweenService:Create(DummyCFrame, Tween_Info, {Value = DummyCFrame.Value * CFrame.Angles(math.pi / (1000 / (Speed / 2)), 0, 0)})
    TweenCrusher:Play()
    TweenCrusher.Completed:Wait()
end
That's interesting. But consider that the "planet" is not empty, there are a lot of items scattered all around. Some of them achored, some of them not. Imagine trying to rotate them all, at the same time, as the planet is rotating. Would be a nightmare lag.
Yes


Just asking there's an easy way to do that, I think if that was possible a very interesting fighting match could take place.
 
Joined
Feb 25, 2018
Messages
217
Ratings
66
Roblox
CallMeKY
Discord
CallMeKY#5012
so, in the end, the question is : how do you make your character get attracted/ pulled by a specific part ?
I had a little time to play around with this today, I was just modifying a BodyForce object depending on where the HumanoidRootPart is relative to the planet. I might add an opposing force when changing regions so you don't float between regions, and I still need to add a BodyGyro, controls, and camera.

I'm open to other ways to do this if anyone has thoughts on it.

https://pastebin.com/H82nhf8p
 
Joined
Feb 24, 2018
Messages
4,052
Ratings
288
Roblox
Typicalgamer_yt11
Discord
trainee #6357
It would be easier to make the planet a sphere and rotate that as the player tries to move. To move the character around a cube you'd definitely need some camera manipulation, and to make the character position horizontal or flipped upside-down you might need a custom control script where you CFrame the character relative to their position around the cube as they "walk". If you use multiple planets, maybe you could use GetMass to determine which planet you're pulled to, and float / fly if you're out of range from everything. Maybe the way I generate satellites in this could help you figure out how to control the character, but it'll probably be quite a bit different if you have flat sides and you wouldn't be using tweens.
Code:
local Amount = 5        -- amount of satellites to generate
local Speed = 1000        -- rotation speed
local TweenTime = 1        -- base tween time. might be modified later depending on speed

local TweenService = game:GetService('TweenService')
local Theta = math.pi * 2 / Amount

-- part generation
local Model = Instance.new('Model', workspace)
local Base = Instance.new('Part')
Base.Shape = Enum.PartType.Cylinder
Base.Size = Vector3.new(10, 10, 10)
Base.Color = Color3.fromRGB(0, 255, 0)
Base.BottomSurface = Enum.SurfaceType.Smooth
Base.TopSurface = Enum.SurfaceType.Smooth
Base.CanCollide = false
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, -20) * CFrame.Angles(0, math.rad(90), 0)
Base.RotVelocity = Vector3.new(0, 0, 50)
Model.PrimaryPart = Base

local Satellite = Instance.new('Part')
Satellite.Shape = Enum.PartType.Block
Satellite.Size = Vector3.new(10, 5, 5)
Satellite.BottomSurface = Enum.SurfaceType.Smooth
Satellite.TopSurface = Enum.SurfaceType.Smooth
Satellite.CanCollide = false

-- generate satellites around the base, pointing at the center
for i = 1, Amount do
    local Angle = Theta * i
    local Size = Base.Size.X
    local X = Size * math.cos(Angle)
    local Y = Size * math.sin(Angle)
    local Z = Base.Position.Z
    local newSatellite = Satellite:Clone()
    newSatellite.Color = Color3.fromRGB(math.random(0, 255), 0, math.random(0, 255))
    newSatellite.Parent = Model
    newSatellite.CFrame = CFrame.new(Vector3.new(X + Base.Position.X, Y + Base.Position.Y, Z), Base.Position) * CFrame.Angles(math.rad(45),0, 0)
    local newWeld = Instance.new('WeldConstraint',Base)
    newWeld.Part0 = Base
    newWeld.Part1 = newSatellite
end

Base.Parent = Model

-- clamp speed. if speed is too high, adjust tween time
Speed = math.clamp(Speed, 100, 10000)
if Speed > 1999 then
    TweenTime = TweenTime / (((Speed - 1999) / 1999) + 1)
    Speed = 1999
end

-- generate tween info and a dummy cframe value to be used for tweens
local Tween_Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local DummyCFrame = Instance.new('CFrameValue')
DummyCFrame.Value = Model:GetPrimaryPartCFrame()
DummyCFrame:GetPropertyChangedSignal('Value'):Connect(function()
    Model:SetPrimaryPartCFrame(DummyCFrame.Value)
end)

-- do the actual tween on a loop, adjusting the tween for its current position
while true do
    local TweenCrusher = TweenService:Create(DummyCFrame, Tween_Info, {Value = DummyCFrame.Value * CFrame.Angles(math.pi / (1000 / (Speed / 2)), 0, 0)})
    TweenCrusher:Play()
    TweenCrusher.Completed:Wait()
end
ur smart af
 
Joined
Jun 4, 2018
Messages
101
Ratings
6
Roblox
proclet
so, in the end, the question is : how do you make your character get attracted/ pulled by a specific part ?
I had a little time to play around with this today, I was just modifying a BodyForce object depending on where the HumanoidRootPart is relative to the planet. I might add an opposing force when changing regions so you don't float between regions, and I still need to add a BodyGyro, controls, and camera.

I'm open to other ways to do this if anyone has thoughts on it.

https://pastebin.com/H82nhf8p
The problem is the orientation of the character. It always stays in an upright position, perpendicular to the Baseplate, even if we delete the Baseplate. Instead of alwaye being perpendicular to the plane he's walking on. So i'm guessing we need to work on the body orientation.

The way I've "solved" the character's body being attracted to a planet is to create a rope constraint. Works pretty well, except for when you have to jump. When you do that, the character is abruptly translated to the projection of the planet attachment point on the Baseplate. The planet's attachment point is (obviously) in the center of the sphere/planet.
Post automatically merged:

P.S. There might be different solutions for a spherical and a cubic "planets". For sphere, I guess we need to be working with a tangent function to solve the orientation.
 
Last edited: