Roblox Forum banner

Help with something

2K views 15 replies 5 participants last post by  3371 
#1 ·
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.
 
#4 ·
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
 
#6 ·
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.
 
  • Like
Reactions: BornToGolf
#13 ·
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
 
  • Like
Reactions: proclet
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top