i am trying to make an fps game in which aiming is a huge part of it but i cant seem to work it out as this is my first project that uses animations, guns etc.
here is my gun script (it is messy rn but i am redoing it currently so it will be clean)
--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
--// Main Variables
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local currentGun = require(ReplicatedStorage.Data.M1911.Settings)
local gun = ReplicatedStorage.Weapons.M1911:Clone()
gun.Parent = Camera
local conf = {}
conf.gun = gun
Player.CharacterAdded:Connect(function(Character)
end)
for i,v in pairs(gun:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("Part") or v:IsA("BasePart") then
v.CanCollide = false
end
end
RunService.RenderStepped:Connect(function()
conf.gun:SetPrimaryPartCFrame(Camera.CFrame*conf.gun.Aim.CFrame)
end)
1 Like
What kind of aim are you aiming for? (puns ha ha)
There are many different adaptations of aim, such as just locking onto the mouse, zooming in, following the mouse, etc.
If you can tell me what kind of aim you’re looking for then I’ll be able to point you in the right direction to what you’ll need to do.
you know how the guns in Phantom forces aim with iron sights? i would like to do it like that and i will also do snipers with zoom sights but i will do that in a further date
Ah, alright. I think what you’ll need to mainly research is FOV (Field Of View), however this is pretty simple.
All though I am not very familiar with working with FOV, I believe you can change it with a few simple lines of code such as:
local camera = workspace.CurrentCamera
camera.FieldOfView = 50
Edit: Oops! Saved early. Sorry!
PS: Heres a helpful link to a page I found on FOV: FOV
this is what i meant by aiming:
(not my image)
1 Like
Oh, Alright.
You may need to create an animation or position it with CFraming to get it to that position, however you’ll need to make sure that it is all controlled around the mouse, basically recreating something like mouse lock.
my game is in first person so it is already locked
Oh, then it’s just the FOV and positioning of the gun.
(Theres also UIS at the beginning however I assume you’ll know that bit already.)
yea, my only problem rn is this: https://gyazo.com/554d510388ba18aa1c1ead50d262f984
the gun disappears when i aim
here is my RBXM for it: gun.rbxm (45.5 KB)
Really, Necro-ing a 5 year old thread?