【发布时间】:2017-02-23 15:11:39
【问题描述】:
我正在以 2D 风格使用 Unity 3D 制作游戏。相机只从左到右跟随玩家,但我希望我的环境有深度感。这不是一个自上而下的游戏,它更像是一个 2d mario 平台游戏。我希望玩家能够在物体前面移动,例如当他们按下时一棵树会在他们身后,如果他们向上按下以进一步回到环境中,那么树现在就在他们面前.
这是我目前为止的动作脚本。
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
Movement ();
}
void Movement(){
anim.SetFloat("Speed", Mathf.Abs (Input.GetAxisRaw ("Horizontal")));
if (Input.GetAxisRaw ("Horizontal") > 0) {
transform.Translate(Vector2.right* 4f*Time.deltaTime);
transform.eulerAngles = new Vector2(0, 0);
}
if (Input.GetAxisRaw ("Horizontal") < 0) {
transform.Translate (Vector2.right * 4f * Time.deltaTime);
transform.eulerAngles = new Vector2 (0, 180);
}
if(Input.GetAxisRaw("Vertical") >0){
transform.Translate (Vector2.up * 4f * Time.deltaTime);
transform.eulerAngles = new Vector2(0, 0);
}
if(Input.GetAxisRaw("Vertical") <0){
transform.Translate (Vector2.down * 4f * Time.deltaTime);
transform.eulerAngles = new Vector2(0, 0);
}
}
}
【问题讨论】:
-
您好,欢迎来到 SO。请务必按原样详细解释您正在处理的预期和当前情况;很难理解您遇到的问题。
标签: c# unity3d unity3d-2dtools depth-buffer