播放器控制器的团结c#

代码示例

3
0

简单的播放器控制的统一

//USES A RIGIDBODY (Unity)//

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
   public float speed;
   
   private Rigidbody rb;
   
   
   
   //Start is called before the first frame update//
   void Start()
   {
       rb = GetComponent<Rigidbody>();
   }
   
   //Update is called once per frame
   void FixedUpdate()
   {
      float moveLR = Input.GetAxis("Horizontal");
      float moveFB = Input.GetAxis("Vertical");
      
      rb.AddForce (new Vector3(speed * moveLR, 0, speed * moveFB));
   }
}

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................