- Home /
Camera Rotate Around Object With Mouse Drag - HELP
Hey guys! I'm new to scripting and I'm in need of some help. I've been trying to make a script that would let me rotate my camera around a game object in the X and Y axis (Depending on mouse movement) using a "Click and Drag". I would like to note that I'm most familiar with JavaScript. (Also, if it's possible to implement velocity, that would be greatly appreciated! But, it's not really important at this stage.)
Thanks! Gabe
Answer by tianjishu · Feb 17, 2012 at 07:08 AM
if ( Input.GetMouseButtonDown( 0 ) ) { mouseClickjudge = true; } if ( Input.GetMouseButtonUp( 0 ) ) { mouseClickjudge = false; } if ( mouseClickjudge ) { transform.RotateAround( bottom.position, bottom.up, Input.GetAxis( "Mouse X" ) * cameraRotateSpeed ); }
This worked great. I was trying to wrap my rotation code in just a Input.Get$$anonymous$$ouseButtonDown( 0 ) but this was only allowing a single click. Using a bool to control access to the rotation function made it work great for a click-and-drag view. Thanks!
Can more context be given to this answer please? $$anonymous$$g. what is bottom set as etc...