The camera moves smoothly within the scene by holding down the right mouse button

Source: Internet
Author: User
<span id="Label3"></p> <ol class="dp-c" style="margin: 0px 0px 1px 45px !important; padding: 0px; border: none; list-style: decimal; color: #5c5c5c" start="1"> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><span style="margin: 0px; padding: 0px; border: none; color: black"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: #006699; font-weight: bold">Using<span style="margin: 0px; padding: 0px; border: none; color: black"> unityengine; </span></span></span></li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "keyword" style= "margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">using<span style=" margin:0px; padding:0px; border:none; color:black ">  system.collections;     </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; color:inherit; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "comment" style= "margin:0px; padding:0px; border:none; Color: #008200 ">//  attach script to camera    <span style="margin:0px; padding:0px; border:none; color:black">   </span> </span> </li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "keyword" style= "margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">public<span style=" margin:0px; padding:0px; border:none; color:black "> <span class=" Keyword " style=" margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">class<span style=" margin:0px; padding:0px; border:none; color:black ">  cameracontroller : monobehaviour {     </span> </span> </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><span style="margin: 0px; padding: 0px; border: none; color: black"><span style="margin:0px; padding:0px; border:none; color:black">    <span class=" Keyword " style=" margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">public<span style=" margin:0px; padding:0px; border:none; color:black "> <span class=" Keyword " style=" margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">float<span style=" margin:0px; padding:0px; border:none; color:black "> moveSpeed  = 10; <span class="comment" style="margin:0px; padding:0px; border:none; color: #008200">//   Set camera movement speed   <span style="margin:0px; padding:0px; border:none; color:black">   </span></span></span></span></span></span></span></span></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">     <span class="keyword" style="margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">void<span style=" margin:0px; padding:0px; border:none; color:black "> Update  ()  {     </span> </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; color:inherit; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "comment" style= "margin:0px; padding:0px; border:none; Color: #008200 ">//  While holding down the right mouse button    <span style="margin:0px; padding:0px; border:none; color:black">   </span> </span> </li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">     <span class="keyword" style="margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">if<span style=" margin:0px; padding:0px; border:none; color:black ">  ( Input.getmousebutton (1))  {     </span> </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; color:inherit; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "comment" style= "margin:0px; padding:0px; border:none; Color: #008200 ">//  Gets the x and Y values of the mouse, multiplied by the speed and time.deltatime because this can be a smoother motion   <span style=" margin:0px; padding:0px; border:none; Color:black ">   </span> </span> </li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">             <span class="keyword" style="margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">float<span style=" margin:0px; padding:0px; border:none; color:black "> h =  input.getaxis (<span class="string" style=" margin:0px; padding:0px; border:none; color:black " "mouse  x "<span )  * movespeed *  time.deltatime;     < span> </span> </span> </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; color:inherit; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">             <span class="keyword" style="margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">float<span style=" margin:0px; padding:0px; border:none; color:black "> v =  input.getaxis (<span class="string" style=" margin:0px; padding:0px; border:none; color:black " "mouse  y "<span )  * movespeed *  time.deltatime;     < span> </span> </span> </span> </span> </li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "comment" style= "margin:0px; padding:0px; border:none; Color: #008200 ">//  Set current camera move, y axis does not change    <span style="margin:0px; padding:0px; border:none; color:black">   </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; color:inherit; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">< Span class= "comment" style= "margin:0px; padding:0px; border:none; Color: #008200 ">//  needs the camera to move in accordance with world coordinates instead of moving according to its own coordinates, so add Spance.world<span style=" margin:0px; padding:0px; border:none; Color:black ">   </span> </span> </li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin:0px!important; padding:0px 3px 0px 10px!important; border-top:none; border-right:none; border-bottom:none; BORDER-LEFT:3PX Solid #6ce26c; list-style-type:decimal-leading-zero; list-style-image:initial; Color: #5c5c5c; line-height:18px; List-style-position:outside!important "><span style=" margin:0px; padding:0px; border:none; color:black ">             <span class="keyword" style="margin:0px; padding:0px; border:none; Color: #006699; Font-weight:bold ">this<span style=" margin:0px; padding:0px; border:none; color:black ">.transform. Translate (h,0,v,space.world);      </span> </span> </span> </li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><span style="margin: 0px; padding: 0px; border: none; color: black">}</span></li></li> <li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: #5c5c5c; line-height: 18px; list-style-position: outside !important"><span style="margin: 0px; padding: 0px; border: none; color: black">}</span></li></li> <li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-top: none; border-right: none; border-bottom: none; border-left: 3px solid #6ce26c; list-style-type: decimal-leading-zero; list-style-image: initial; color: inherit; line-height: 18px; list-style-position: outside !important"><span style="margin: 0px; padding: 0px; border: none; color: black">}</span></li></li> </ol><p><p>The camera moves smoothly within the scene by holding down the right mouse button</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.