using UnityEngine;
public class PlayerContrller1 : MonoBehaviour
{
private Transform mmTransform;
private Rigidbody mmRigidbody;
void Start ()
{
mmTransform=gameObject.GetComponent<Transform>();
mmRigidbody=gameObject.GetComponent<Rigidbody>();
}
void Update ()
{
PlayerMove();
}
//Method
private void PlayerMove()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 dir = new Vector3(h, 0, v);
mmRigidbody.MovePosition(mmTransform.position + dir * 0.2f);
}
}
Input input key settings.
Upper menu bar: edit=>Project settings=>input
Similar Posts:
- Unity – NullReferenceException: Object reference not set to an instance of an object
- Unity realizes lookat in 2D
- Limit the range of axial movement in unity mathf.clamp
- Failed to create agent because it is not close enough to the NavMesh
- Error: Setting the parent of a transform which resides in a Prefab Asset is…
- [leetcode] 280. Wiggle sort
- Unit delay methods: invoke and invokerepeating
- Keras.utils.to in keras_ Categorical method
- Android Exception: UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOExcepti
- Tag code error valueerror: bad input shape()