zoukankan      html  css  js  c++  java
  • 朋友帮忙写的代码

    --------------每次旋转60度---------------------

    var rotating : boolean = false;
    var rotateSpeed : int = 12;
    function OnGUI()
    {
         if(GUILayout.Button("Rotateme"))
      {
      rotating=true;
      SendMessage("Rotateme");
      } 
    }

    function Rotateme()
    {
       if (rotating)
       { 
          var curRotate : float = 0;
          var startRotate : float = transform.eulerAngles.y;
          while (curRotate < 60)
       {
             curRotate += rotateSpeed * Time.deltaTime;
       print(curRotate);
             transform.eulerAngles.y = startRotate + curRotate;
             yield;
          }
          transform.eulerAngles.y = Mathf.Round(startRotate + 60);
          rotating = false;
       }
    }

    -----------旋转朝向目标--------------------------

    var targetTransform: Transform;
    var rotationSpeed : float=5.0;
    function Update ()
    {
     var direction:Vector3=targetTransform.position-transform.position;
     direction.y=0;
     transform.rotation = Quaternion.RotateTowards (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed);
    }

  • 相关阅读:
    CSS知识总结一
    Html知识总结一
    转:B/S和C/S结构的区别
    转:理解本真的 REST 架构风格
    转载:简洁明了说明RESTful架构是什么
    名词理解
    转: 如何理解API,API 是如何工作的
    WEB的理解
    开关按钮的实现
    ssm学习之ssm框架详解
  • 原文地址:https://www.cnblogs.com/softimagewht/p/1913972.html
Copyright © 2011-2022 走看看