📜  如何在 unity 2020 中移动二维字符 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:12.289000             🧑  作者: Mango

代码示例2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovemeny : MonoBehaviour{

    public float speed;

    private Rigidbody2D rd;

    void Start(){
        rb = GetComponent();

    }
    void Update() {

        Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))
        moveVelocity = moveInput * speed;
    }

   void FixedUpdate(){

        rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);

    }

}