小编Jor*_*nie的帖子

Unity - 游戏对象看鼠标

我遇到了问题。

我现在拥有的基本设置有两个对象:我的相机和我的播放器对象。

玩家通过 WASD 上的变换移动,并且应该随着鼠标移动而旋转。

摄像机自上而下(以轻微的“3ps”风格角度,使玩家对象保持在摄像机视角的中心,并根据玩家的旋转进行旋转。

这是玩家移动脚本:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour 
{
    public int playerSpeed = 8;  //players movement speed

    void Update () {
        if (Input.GetKey ("w")) 
        {
            transform.Translate (Vector3.forward * Time.deltaTime * playerSpeed); //move forward
        }  
        if (Input.GetKey ("s")) 
        {
            transform.Translate (Vector3.back * Time.deltaTime * playerSpeed); //move backwards
        }  
        if (Input.GetKey ("a")) 
        {
            transform.Translate (Vector3.left * Time.deltaTime * playerSpeed); //move left
        }  
        if (Input.GetKey ("d")) 
        {
            transform.Translate (Vector3.right * Time.deltaTime * playerSpeed); //move right …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine unityscript

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

unity-game-engine ×1

unityscript ×1