zoukankan      html  css  js  c++  java
  • Rigidbody相关的操作最好放在FixedUpdate中,update中可能会无效果

    void Turning()
    {

    // Create a ray from the mouse cursor on screen in the direction of the camera.
    Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

    // Create a RaycastHit variable to store information about what was hit by the ray.
    RaycastHit floorHit;

    // Perform the raycast and if it hits something on the floor layer...
    if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask))
    {

    // Create a vector from the player to the point on the floor the raycast from the mouse hit.
    Vector3 playerToMouse = floorHit.point - transform.position;

    // Ensure the vector is entirely along the floor plane.
    playerToMouse.y = 0f;

    // Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
    Quaternion newRotatation = Quaternion.LookRotation(playerToMouse);

    // Set the player's rotation to this new rotation.
    m_Rigidbody.MoveRotation(newRotatation);

    }

  • 相关阅读:
    各种
    shell
    搭建个人信息平台
    基本tomcat+nginx
    vi编辑的使用
    linux权限管理
    Java观察者模式
    Flume+Kafka+Sparkstreaming日志分析
    科学计算与数学建模
    推荐系统起手式-几种简单推荐模型(基于内容的推荐)
  • 原文地址:https://www.cnblogs.com/alps/p/6115704.html
Copyright © 2011-2022 走看看