It’s okay! It’s Recommended to check it first though.
Also, is this question solved yet?
It’s okay! It’s Recommended to check it first though.
Also, is this question solved yet?
I’m a little confused. Why is it ToEulerAnglesYXZ
when you’re doing local x, y, z
? Why is it not ToEulerAnglesXYZ
?
Is it because of complicated math stuff?
idk if this has been solved yet, but I’ve worked on sophisticated systems for recoil and recoil return.
What you want to do is add more clarity to your recoil system. I mean like add a table containing your recoil pattern. It could look something like this:
myRecoilPattern = {
{10, {.2,0,.8},{-.2,0} },
{20, {.5,0,.5},{-.5,0} },
{30, {.4,0,.5},{-.4,0} },
}
--// for each index in myRecoilPattern, below is the template
--// {tillWhichBullet, {upRecoil, rightRecoil, forHowLong}, {upReturn, rightReturn, forHowLong?} }
so what you could do in your self.Recoil:Fire() line is
local function getCalculatedRecoil(whichBullet) --// note that this number depends on the burstCount, not the position of the bullet in the magazine.
for _, recoilTable do
if whichBullet < recoilTable[1] then
return recoilTable
end
end
end
while mouseHeld do
if fireRateChecksOut then
self.Recoil:Fire(getCalculatedRecoil())
end
runS:Wait()
end
--// then wherever you are receiving that signal,
local recoilTable = --//receive this through signal
local timePassed = 0
local direction = 0
local myRecoilLoop = runS.OnRenderStep:Connect(function(dt)
timePassed += dt
if timePassed > recoilTable[2][3] then
direction += 1
end
if direction == 0 then
cam.CFrame *= CFrame.Angles(recoilTable[2][1] * dt,recoilTable[2][2] * dt)
elseif direction == 1 then
cam.CFrame *= CFrame.Angles(recoilTable[3][1] * dt, recoilTable[3][2] * dt)
end
end)
this is only to show you the general structure of more sophisticated recoil systems. I’m sure you can add more to it yourself.
Have Fun!
ALSO REMEMBER TO DISCONNECT THE RENDERSTEP AFTER USE myRecoilLoop:Disconnect()
There are 2 ways:
• You could use CFrame - CFrame.Position if you want the Cframe without its position.
• You can use local X, Y, Z = CFrame:ToOrientation()
if you need the values for mirroring or printing them etc. !
Also no need for math.deg() etc. you can just grab one of the angles and do something like this:
local X, Y, Z = MyCFrame:ToOrientation()
print(X / math.pi * 180, Y / math.pi * 180, Z / math.pi * 180)
And if you need it as a vector just do this:
local Rot = Vector3.new(MyCFrame:ToOrientation()) / math.pi * 180
print(Rot)