Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Can335 committed Sep 1, 2024
2 parents a141875 + a555a89 commit a558b7c
Show file tree
Hide file tree
Showing 9 changed files with 935 additions and 1 deletion.
3 changes: 2 additions & 1 deletion default.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
}
},
"ReplicatedStorage": {
"$path": "src/ReplicatedStorage"
"$path": "src/ReplicatedStorage",
"$ignoreUnknownInstances": true
},
"StarterPlayer": {
"StarterCharacterScripts": {
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/ReplicatedStorage/Gun.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local types = require(script.Parent.types)

local Gun = {}
Gun.__index = Gun

function Gun.new(): types.Gun
local self = setmetatable({}, Gun)

return self
end

return Gun
23 changes: 23 additions & 0 deletions src/ReplicatedStorage/Viewmodel/Arms.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local types = require(script.Parent.Parent.types)

local Arms = {}
Arms.__index = Arms

type _Arms = types.Arms & {
model: Model,
gun: types.Gun,
}

function Arms.new(model: Model, gun: types.Gun)
local self = setmetatable({
model = model,
gun = gun,
}, Arms)

return self
end

function Arms.Update(self: _Arms)
end

return Arms
37 changes: 37 additions & 0 deletions src/ReplicatedStorage/Viewmodel/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local currentCamera = workspace.CurrentCamera

local types = require(script.Parent.types)
local Arms = require(script.Arms)

local Viewmodel = {}
Viewmodel.__index = Viewmodel

type _Viewmodel = types.Viewmodel & {
arms: types.Arms,
}

--TODO: Accept the 5 weapon slots.
function Viewmodel.new(viewmodel: Model, gun: types.Gun): types.Viewmodel
local model = viewmodel:Clone()
model.Parent = currentCamera

local self = setmetatable({
model = model,
arms = Arms.new(model, gun),
}, Viewmodel)

self:Enable()

return self
end

function Viewmodel.Enable(self: _Viewmodel)
self.model:PivotTo(currentCamera.CFrame)
end

function Viewmodel.Update(self: _Viewmodel)
self.model:PivotTo(currentCamera.CFrame)
self.arms:Update()
end

return Viewmodel
Loading

0 comments on commit a558b7c

Please sign in to comment.