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

How to disable camera movement with "<" and ">" key?

Asked by
ItsMeKlc 235 Moderation Voter
8 years ago

Whenever you use the keys "<" and ">", ROBLOX rotates your camera by 90 degrees in its respective direction. Is there any way to prevent this?

0
I would think setting the CurrentCamera to scriptable would do it. M39a9am3R 3210 — 8y
0
That comes with a whole new set of problems, I'd have to completely remake the camera follow script... ItsMeKlc 235 — 8y
0
pressing < and > doesn't do anything to the camera... Do you mean , and . ? XAXA 1569 — 8y
0
Period, and "<" share key on my keyboard lol ItsMeKlc 235 — 8y

3 answers

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
8 years ago

An alternative would be to copy the default control scripts and modify them slightly. Here's a step-by-step:

  1. Play a game in studio so that your character spawns.
  2. Copy the CameraScript found under game.Players.Player.PlayerScripts.
  3. Stop the game. Paste the script into game.StarterPlayer.StarterPlayerScripts. This will replace the default camera script whenever the player enters the game. Now you can start editing.
  4. Go to the module CameraScript.RootCamera. You should see something like this, starting at line 494:
--[[elseif input.KeyCode == Enum.KeyCode.Comma then
                local angle = rotateVectorByAngleAndRound(this:GetCameraLook() * Vector3.new(1,0,1), -eight2Pi * (3/4), eight2Pi)
                if angle ~= 0 then
                    this.RotateInput = this.RotateInput + Vector2.new(angle, 0)
                    this.LastUserPanCamera = tick()
                    this.LastCameraTransform = nil
                end
            elseif input.KeyCode == Enum.KeyCode.Period then
                local angle = rotateVectorByAngleAndRound(this:GetCameraLook() * Vector3.new(1,0,1), eight2Pi * (3/4), eight2Pi)
                if angle ~= 0 then
                    this.RotateInput = this.RotateInput + Vector2.new(angle, 0)
                    this.LastUserPanCamera = tick()
                    this.LastCameraTransform = nil
                end]]

comment these statements out (I did it for you already). This should unbind the , and . keys from controlling your camera!

Ad
Log in to vote
0
Answered by 8 years ago

There's no real way to disable keys that are being used by roblox. You can try assigning the key to do something, but it won't really do anything.

Log in to vote
0
Answered by 8 years ago

You can use ContextActionService's BindAction method to get input from these keys, which will block ROBLOX's camera manipulation code from receiving them. Also keep in mind that they use the comma and period keys, not their shifted alternatives greater than and less than.

0
Okay, I'm not quite sure how to use this (I didn't quite understand the wiki) so can you give me an example please? Also just to make sure, after I block ROBLOX from using the keys, could I use them for my own need? ItsMeKlc 235 — 8y

Answer this question