# \[HELP\] Mouse orbit on right mouse click script

**URL:** https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457
**Category:** Scripting
**Tags:** Scripting
**Created:** [October 23, 2010, 3:59pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457 "2010-10-23T15:59:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_67725642](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@anon\_67725642](https://discussions.unity.com/u/anon_67725642)
#### Post date: [October 23, 2010, 3:59pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/1 "2010-10-23T15:59:23Z")

</div>

this is something i should be abule to work out on my own but its been a while since i have tried any scripting  
i am using [this](http://www.unifycommunity.com/wiki/index.php?title=MouseOrbitImproved) script and i am trying to work out a way to make the camera rotate only when the right or left mouse button is held. any help would be appreciated 🙂

---

<div class="post-metadata">

### Author: ![anon\_42117051](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@anon\_42117051](https://discussions.unity.com/u/anon_42117051)
#### Post date: [October 23, 2010, 4:17pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/2 "2010-10-23T16:17:30Z")

</div>

Your question here is nothing to do with camera rotation.

To detect a mouse click, you can use

if (Input.GetButton (“Fire1”)) {  
//only execute this code if Fire1 is pressed, which is mapped to left mouse by default  
}

Find the part of the code that does the rotation and wrap it with something like the above.

Maybe somebody will modify that script to do what you want, but in my opinion you should try to use this code and check out some scripting tutorials otherwise you’re going to find yourself resorting to the forum for every single issue you come across in the future.

You can find some info and short examples of detecting key and mouse presses at the official docs here: [Unity - Scripting API: Input](http://unity3d.com/support/documentation/ScriptReference/Input.html)

---

<div class="post-metadata">

### Author: ![anon\_67725642](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@anon\_67725642](https://discussions.unity.com/u/anon_67725642)
#### Post date: [October 23, 2010, 4:36pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/3 "2010-10-23T16:36:15Z")

</div>

im not looking for someone to do it for me just some tips how to do it.  
i am trying to relearn the java i had worked out in the past and build on top of that

thanks for the tip

---

<div class="post-metadata">

### Author: ![AkilaeTribe](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/akilaetribe/32/153898_2.png) [@AkilaeTribe](https://discussions.unity.com/u/AkilaeTribe)
#### Post date: [October 23, 2010, 4:39pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/4 "2010-10-23T16:39:45Z")

</div>

Find all the code stuff which makes the camera rotate…

And put it between : if (Input.GetButton (“Fire1”)) {

and : }

So it is only executed when you hold the left click.

As explicitly suggested by xomg.

---

<div class="post-metadata">

### Author: ![darkben](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@darkben](https://discussions.unity.com/u/darkben)
#### Post date: [April 10, 2011, 8:32am UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/5 "2011-04-10T08:32:08Z")

</div>

I’ve tried this, I don’t know if I’m picking the wrong bit of code or anything, but I always get an error saying "expecting (, lateUpdate) (late update refers to the function i wrapped the if function around)

basically, it doesn’t work 😛  
would it work if I did it around the entire script?

---

<div class="post-metadata">

### Author: ![bigmisterb](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/bigmisterb/32/406611_2.png) [@bigmisterb](https://discussions.unity.com/u/bigmisterb)
#### Post date: [April 10, 2011, 2:09pm UTC](https://discussions.unity.com/t/help-mouse-orbit-on-right-mouse-click-script/426457/6 "2011-04-10T14:09:19Z")

</div>

[poke poke… I just answered the same question for the left mouse button](http://forum.unity3d.com/threads/85144-Camera-Orbit)
