Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a part 2D?

Asked by 10 years ago

I've successfully made the game 2D, which means I can't move sidewards I can only move up and down the path, (come to my game for more information as it's hard too explain, game is called Soccer Physics 2 by SoccerPhysics).

I don't know how too make the Part, which is a football, I'm not exactly sure how too make a "football" 2D. Here is the original 2D Script, could you change this for it too be a part, or would I have to make a completely different script?

2D SCRIPT:

function GetMass(object)
    local mass = 0
    if pcall(function() return object:GetMass() end) then
        mass = object:GetMass()
    end
    for _,child in pairs(object:GetChildren()) do
        mass = mass + GetMass(child)
    end
    return mass
end

function onPlayerRespawned(newPlayer)
    wait()
    local torso = newPlayer.Character.Torso 
    local bp = Instance.new("BodyPosition")
    bp.Name = "TwoD"
    bp.position = torso.Position
    bp.P = 1000000
    bp.D = 1000
    bp.maxForce = Vector3.new(0, 0, 1000000)
    bp.Parent = torso
    local bf = Instance.new("BodyForce")
    bf.force = Vector3.new(0, 100*GetMass(newPlayer.Character), 0)
    bf.Parent = torso
    newPlayer.Character.Humanoid.WalkSpeed = 24
    script.LocalScript:Clone().Parent = torso.Parent
    newPlayer.Character.DescendantAdded:connect(function()
        bf.force = Vector3.new(0, 100*GetMass(newPlayer.Character), 0)
    end)
    newPlayer.Character.DescendantRemoving:connect(function()
        bf.force = Vector3.new(0, 100*GetMass(newPlayer.Character), 0)
    end)
end

function onPlayerEntered(newPlayer)
    if newPlayer.Character then
        onPlayerRespawned(newPlayer)
    end
    newPlayer.Changed:connect(function (property)
        if (property == "Character") and newPlayer.Character then
            onPlayerRespawned(newPlayer)
        end
    end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)

Local Script Inside of 2D SCRIPT:

lockCamera = true
    distance = 30
    height = 3

local torso = script.Parent.Torso
local center = Instance.new("Part")
center.Name = script.Parent.Name .. " Center"
center.Transparency = 1
center.CanCollide = false
center.Size = Vector3.new(1,1,1)
center.Position = torso.Position
center.CFrame = CFrame.new(Vector3.new(0,0,0),Vector3.new(0,0,-1))
center.Parent = game.Workspace
local bp = Instance.new("BodyPosition")
bp.position = center.Position
bp.maxForce = Vector3.new(1000000, 1000000, 1000000)
bp.Parent = center
local bg = Instance.new("BodyGyro")
bg.maxTorque = Vector3.new(9e+005, 9e+005, 9e+005)
bg.cframe = center.CFrame
bg.Parent = center
local cam = game.Workspace.CurrentCamera
cam.CameraSubject = center
cam.CameraType = Enum.CameraType.Attach

while torso.Parent do
    wait()
    center.BodyPosition.position = torso.Position
    if lockCamera then
        cam.CoordinateFrame = CFrame.new(Vector3.new(center.Position.x + distance,center.Position.y + height,center.Position.z))
    end
end

center:Remove()

0
I'm still not answering until you apologize for that comment on one of your questions... Shawnyg 4330 — 10y
0
What do you mean, what comment?... SoccerPhysics 20 — 10y
0
Why are you coming here saying I need to apologize for nothing, I just joined today, and then dislike my post making me lose reputation... SoccerPhysics 20 — 10y

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

It is not possible to make a part two dimensional. It will always have an x, y, and z for its size. You could make a very flat block, but not truly 2D. Another possible solution would be to make a transparency block, then put a Decal on it.

This is what you mean, right?

Ad
Log in to vote
0
Answered by
RM0d 305 Moderation Voter
10 years ago

This is not a question about code. But heres a 2d Part. http://www.roblox.com/2D-part-item?id=170350729

0
Its has mesh. It looks 2d( it is visualy) its z = 0. RM0d 305 — 10y

Answer this question