- Home /
Switch between mouse controller character to controlling camera?
want to let mouse input control player aim and be able to toggle on camera control via mouse.
plan to have one block of script in which the mouse input is used to control player movement in 3rd person.
second block of script will allow the mouse input to control the orbit of the camera rather than player movement.
-What type of code should I write to toggle between the two modes? Should it be something like:
if keypressed
{mouse controls the camera}
else
{mouse controls the player}
Or should it be:
var camerastate = 0
onkeydown camerastate = 1
onkeyup camerastate = 0
case camerastate 1: {mouse controls the camera}
camerastate 0: {mouse controls the player}
I feel like using if/else to check which block of script to be using to handle mouse input is not the right way to do it? But it doesn't seem using case/switch is the appropriate way to toggle between control modes.
I would use if/else ... it's simple, it will work and it is readable.
Your answer
Follow this Question
Related Questions
Toggle Scripts On & Off 1 Answer
Check GUI toggle button with the M keyboar Key 2 Answers
Is it a bad idea to add and remove listeners for toggles and buttons at runtime? 2 Answers
GUI window help 1 Answer