# Управление героем

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

public class aaa : MonoBehaviour {
    // rotating fields
    private float rotationX = 0.0f;
    private float rotationY = 0.0f;
    private float speedRotating = 7.0f;
    // moving fields
    private float speedMoving = 8.5f;

    void Start () {
        Rigidbody rigidBody = GetComponent<Rigidbody>();
        if(rigidBody != null)
        {
            rigidBody.freezeRotation = true;
        }
    }

    void Update () {
        // rotating
        rotationX -= Input.GetAxis("Mouse Y") * speedRotating;
        rotationX = Mathf.Clamp(rotationX, -45, 45);
        float delta = Input.GetAxis("Mouse X") * speedRotating;
        rotationY = transform.localEulerAngles.y + delta;
        transform.localEulerAngles = new Vector3(rotationX, rotationY, 0);
        // moving
        float moveX = Input.GetAxis("Horizontal") * speedMoving;
        float moveZ = Input.GetAxis("Vertical") * speedMoving;
        transform.Translate(moveX * Time.deltaTime, 0, moveZ * Time.deltaTime);
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maxim218.gitbook.io/unity/upravlenie-geroem.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
