zoukankan      html  css  js  c++  java
  • Unity 准心和视角旋转

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    /// <summary>
    /// 视角移动
    /// </summary>
    public class CameraCollider : MonoBehaviour
    {
    public Camera cameragame;
    // Start is called before the first frame update
    void Start()
    {

    }
    public float inputspeed=1f;//控制键速度
    // Update is called once per frame
    void Update()
    {
    float X = (Input.mousePosition.x - Screen.width / 2f)/(Screen.width/2);
    float Y = (Input.mousePosition.y - Screen.height / 2f)/(Screen.height/2);


    cameragame.transform.Rotate(Vector3.left*Y* inputspeed);//摄像机上下旋转

    transform.Rotate(Vector3.up * X* inputspeed);//角色左右旋转
    cameragame.transform.eulerAngles = new Vector3(cameragame.transform.eulerAngles.x,cameragame.transform.eulerAngles.y,0);//锁定自旋转
    }

    }

    代码

    加一个3D图片 在摄像机前面

  • 相关阅读:
    公输盘
    电脑机器刷BIOS
    八皇后问题的实现
    安装msdn出现的问题及解决
    加密推荐书籍
    C++待解
    atan()与atan2()
    Win32/MFC/COM学习推荐书籍
    C++问题
    windows2000 sp4下载
  • 原文地址:https://www.cnblogs.com/suiyi78/p/13264452.html
Copyright © 2011-2022 走看看