#Fixed camera with 45 degree increments
1 messages · Page 1 of 1 (latest)
-
The math is not that advanced
-
look up a tutorial
-
if all else fails here is mine (top-down camera, the principals remain the same):
local cam = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local TS = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local maxZoom = 25
local ScrollMulti = 2
task.wait(.5)
local NewCam = game.Workspace.NewPCamera
local function SetCamera()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = NewCam.CFrame
end
local function Scroll()
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel then
local Position = input.Position.Z
if Position > 0 then
if cam.FieldOfView - (1 * ScrollMulti) >= 70 - maxZoom then
cam.FieldOfView -= Position * ScrollMulti
elseif cam.FieldOfView - (1 * ScrollMulti) < 70 - maxZoom then
cam.FieldOfView = 70 - maxZoom
end
elseif Position < 0 then
if cam.FieldOfView + (1 * ScrollMulti) <= 70 + maxZoom then
cam.FieldOfView -= Position * ScrollMulti
elseif cam.FieldOfView + (1 * ScrollMulti) > 70 + maxZoom then
cam.FieldOfView = 70 + maxZoom
end
end
end
end)
end
local function CheckForMovement()
local KeysBeingHeld = {}
local TimeForSmooth = .1
local function SmoothMovement(NextStep)
local info = TweenInfo.new(
TimeForSmooth,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut
)
local tween = TS:Create(cam, info, {CFrame = NextStep})
tween:Play()
tween.Completed:Wait()
end
local function ContinueMovement()
while true do
local NewVelocity = CFrame.new(0,0,0)
for Key in pairs(KeysBeingHeld) do
if Key == "W" then
NewVelocity = NewVelocity * CFrame.new(0,4,0)
elseif Key == "A" then
NewVelocity = NewVelocity * CFrame.new(-4,0,0)
elseif Key == "S" then
NewVelocity = NewVelocity * CFrame.new(0,-4, 0)
elseif Key == "D" then
NewVelocity = NewVelocity * CFrame.new(4,0, 0)
end
end
if KeysBeingHeld["LeftShift"] then
NewVelocity = CFrame.new(NewVelocity.Position * 2)
end
SmoothMovement(cam.CFrame * NewVelocity)
end
end
UIS.InputBegan:Connect(function(input)
local key = input.KeyCode.Name
if key == "W" then
KeysBeingHeld["W"] = true
elseif key == "A" then
KeysBeingHeld["A"] = true
elseif key == "S" then
KeysBeingHeld["S"] = true
elseif key == "D" then
KeysBeingHeld["D"] = true
elseif key == "LeftShift" then
KeysBeingHeld["LeftShift"] = true
end
end)
UIS.InputEnded:Connect(function(input)
local key = input.KeyCode.Name
if key == "W" then
KeysBeingHeld["W"] = nil
elseif key == "A" then
KeysBeingHeld["A"] = nil
elseif key == "S" then
KeysBeingHeld["S"] = nil
elseif key == "D" then
KeysBeingHeld["D"] = nil
elseif key == "LeftShift" then
KeysBeingHeld["LeftShift"] = nil
end
end)
coroutine.wrap(ContinueMovement)()
end
SetCamera()
task.wait()
Scroll()
CheckForMovement()
put this into StarterCharacterScripts
yeah, i usually say that cuz the last time i did that i had to relearn dot products, vectors, and some other.. not happy things
" UIS.InputBegan:Connect(function(input)
local key = input.KeyCode.Name
if key == "W" then
KeysBeingHeld["W"] = true
elseif key == "A" then
KeysBeingHeld["A"] = true
elseif key == "S" then
KeysBeingHeld["S"] = true
elseif key == "D" then
KeysBeingHeld["D"] = true
elseif key == "LeftShift" then
KeysBeingHeld["LeftShift"] = true
end" 💔
cant you just use the magnitude
actually no
but js let me do ts
yeah doesnt work
woohoo
time for the debugging process
or js try again to do it
also misses some key points i made
in the question
well then why answer if it doesnt work, and B, misses allat
⛓️💥❤️🩹
read it, it's legimately a 1 step set up process
oh yeah
also the topdown camera u provided that i tested
doesnt work as topdown either 💔
but hey
yet it does 🥀
1, clearly disproven based on my camera experience
12th grade? im going into NINTH 😭
also
2:
gng what are you talking about 😭
im here BECAUSE i cant find a tutorial
🥀
if you're "so advanced" 🐺 then why couldnt you just read it 🥀
i did
reading -1 moment 📖
1: Disproven, the math i need is not my grade level, infact beyond
2: No tutorials i can find, hence im here
3: ur cam script sucks ass
did you read what you wrote??
- why does that matter, mathematics and intuitive skills are intertwined and yet so vastly different
- search harder (it takes everyone atleast 10 minutes to find a good one)
- because you didn't read it 🌹
- no 🥀
- searched for the past couple o hours on devforums, youtube, etc
- "(top-down camera, the principals remain the same)", even yet still broken still spits out like 800 errors, etc
so yeah
"no" 🤡
⬇️ Download the full script and models: https://buzzy.gg/roblox-studio-tutorials/
👉 More Roblox Studio Tutorials and Scripts: https://buzzy.gg/roblox-studio-tutorials/
👉 Join our Discord & Forums for more help: https://buzzy.gg/
⭐️ Watch these related Tutorials:
How to make a Tool: https://www.youtube.com/watch?v=ouSv6TobRzw
How...
a fixed player camera at an offset with 45 degree rotational increments with interpolation or tweens to prevent immediate snapping
💔
bro is <3rd grade ELA
I dont think you understand 🥀
dot product isint rocket science
you are never going to find a tutorial that specific
yeah ik
i still figured it out hopefully 🙏
hence
why do you think i am here
just make it yourself 🙏
gang
that's why im here
i do NOT kno how 🙏
read the question
i do NOT know roblox player camera manipulation
how do you expect to improve if you wont try 🥀
i have already spend long enough trying
let me finish 💔
introduced, yet it's not a hard subject to learn
⏫
ive spent the past 2 days reading docs and trying to make it work
i js restarted cuz it was that bad
reading < doing
and (hopefully) you walked out better at what you do?
"reading < doing" what the FUCK do you think roblox dev docs are for?
development skills of a rock 🙏
not really but kinda
i got some cool stuff to work with help
ur not only meant to be reading the docs lol
am i supposed to use the 1000 typewriter monkey strat :broken:
because chat
i read the docs
interperet
and seek help (WHY IM HERE 😭
its literally #1020374354867007528 my FAMILY my BROTHA my FELLA
when i need it
and this is one of a few cases my guy
ask help for simpler, less specific things, not "can you guys do my whole project for me"
yeah
but how do i do anything without a start 💔
i dont even kno what i am supposed to do my fella
and i looked at ur script
are you fucking serious 🙏
yes, im TRYING my guy 😭
but i cant get shit that works but im supposed to make allat work somehow
1000 monkey typewriter methodry
do you realize
its okay to js ask for some help?
and ur like "but no wahh wahh not whole project"
my FELLA
my BROTHA
my ASSOCIATE
js let me ask for help
and im gonna say smthn so let me type this time
i read the docs, RIGHT? SO I LEARN RIGHT? How ive been taught is by reading, so obviously.
I then interperet as sich, apply the knowledge
and it works
i still cant tell what youe asking
scroll to top
but when I cant figure it out, cant find a proper tutorial, etc,
yea its too vague
I'm stupid for asking?
lock the camera within a degree range?
kindaa
like
you have a locked view looking at char
i can kinda do that??
but
45 degree increments with tweening/interpolation
is giving me a fucking aneurysm
because my guy
i js dont get it
😲
and i need help 🤯
so im going to go back to trying ts 500 different ways and come back in another 2 days because apparently that's the right way to do it?
cyas
wdym 45 degree increments
like
when those games where you press < or > and it aligns the camera
but only that
and no snapping, but like
interpolate or tween it for a smooth transition?
because unless ur that one mariocart, more than 8 directions on a sprite is a bit crazy
for a SPRITE?
for 2d in 3d
what are u really trying to do
yk like baldis basics
where bladi is 2d
its that
but the angle changes
like the back and front of a sprite dependent on if ur looking from the back or the front
and the part i need help with
but baldi always looks straight at you
is the camera that can look around
yeah ik
this is diff
the sprite follows, but the direction they're facing changes(??)
something like that
like yk og mariocart sprites?
let me get u a vid example
no?
you move
camera stays until moved by the q or e in 45 or -45 repsectively or what ever is left and right im js lost
what part of this are you trying to replicate
yk how
** You are now Level 8! **
the mariokarter
lets say
the direction is always flat to the camera, right?
but the drawing of the sprite rotates
yea
like when u animate a 2d area and on that area a 3d object rotates
the 2d object is the enemy
but
oh i see what youre tryign to do now
yea
so yeah
8 different 2d sprites, pick the one that makes the enemy look like its looking at you
yes
well
it would look in one direction but
the sprites would change based off of your direction
like a 2.5d i think it is?
like the actual world gui is still facing one way but the sprite is changing
and those directions are those 45 degree increments
the sprite's direction is determined by the player's camera's view vector (is it?) and then calculates some mathy shit ( i cant understand it ) to determine what sprite it should use so the part faces the player but it looks like the sprite is turning
i think you can pair each sprite(put them all in a table or something) with a direction that its facing(lets call this A for all of them) and then also take the vector pointing from the sprite gui to the player(lets call it B) and then iterate over each A vector and pick the one that has the highest value from the dot product A.B
well it should be the direction from the sprite to the player
its player projecting their view of the sprite
but i see
i think?
but the perspective changing triggers the sprite (based on the 45 degree incremented camera i need) so it rotates away/towards based on the sprite's own view vector (prob js a part it points to ill do or smthn)
you should just be able to do some cframe math to make the directions paired with the sprites actually point the correct way in the world( enemy.CFrame.Rotation:PointToWorldVector(sprite_dir) .CFrame.Rotation just gets the cframe without position cuz its unnecessary for these unit vecotrs, and then PointToWorldVector pretty much makes it so that for example 1, 0, 0 would be turned into the RightVector for the enemy.CFrame and i hope you can extrapolate to the rest)
well
with point to world
would that be the sprite's own direction? (seperate from the part that rotates to the player)
because
let me say my thingy
the view of the sprite changes based on where it goes n stuff
sp
if the player sees it moving
it would see the front then when turning to see it walk away see its back
so idk man im just lost
its very complicated for me which goofy goober didn't understand and just berated me for it
basically it will rotate the sprite vec that originalyl didint care about where the enemy is facing by how much the enemy is rotate
let me draw but i think thats right
and like
8-directionals
so ngl
its actually like how doom did it
i should have said THAT
HWEQETHETHBNA
but not really how they did it
the way im doing it is a far ways different
npc is red, sprite direction chosen is blue, purple is the direction vector enemy->playre, player is green dot, you can see blue direction is the most aligned(dot product shows how aligned 2 vectors are) and why its chosen
yeah
like this, small part is the enemie's sprite's look direction
but
the big flat panel would turn to you
and show the apropriate sprite based on ur perspective
yea
so yeah
so i needa make the camera, say when it updates
and since its an interpolation/tween
update the view 1/2 way thru
so when you turn
the npc looks like it's turning too
based on ur perspective
let me draw
nothing should happen to the sprite when you turn your camera
the camera snaps onto the npc?
if half way below 45 and half way above -45
the view remains the same
yk
so when you turn ur camera (above the half-way-45)
it turns with you kinda???
so if the player is roughly looking at the npc nothing happens, but if you turn too much, theres a lerp back to the middle
oh shoot i gtg
there's a lerp that says "oh shoot i need to rotate here so persppective" idk
ill figure it out i hope
I'm back sorry for the afk, had to do stuff around the house
HI