برای اینکه یک rigidbody رو با کیبرد یا موس تکون بدید از کد زیر استفاده می کنیم.


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

 public class NewBehaviourScript : MonoBehaviour {     public float speed;     private Rigidbody rb;     void Start ()     {         rb = GetComponent<Rigidbody>();     }     void FixedUpdate ()     {         float moveHorizontal = Input.GetAxis ("Horizontal");         float moveVertical = Input.GetAxis ("Vertical");         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);         rb.AddForce (movement * speed);     }
}
خب اول یک متغییر از جنس rigidbody میسازیم . در قسمت استارت اون شی رو به متغییری که تعریف کردیم اضافه می کنیم. در FixUpdate دو خط اول ورودی ها رو اسکن میکنه ، خط بعدی یک متغییر از نوع Vector3 میسازه ، و در اخر هم با تابع addforce به جسم نیرو وارد میکنیم