Answer the question
In order to leave comments, you need to log in
The CharacterController does not contain a Move definition. What's the catch?
The code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterController : MonoBehaviour
{
[SerializeField][Range(-3,3)] float Sensitivity;
[SerializeField] Transform Camera;
[SerializeField] CharacterController controller;
float CameraPitch;
private void Start()
{
controller = GetComponent<CharacterController>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
MouseMoving();
Moving();
}
void MouseMoving()
{
Vector2 MouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
CameraPitch -= MouseDelta.y * Sensitivity;
Mathf.Clamp(CameraPitch, -90, 90);
Camera.localEulerAngles = Vector3.right * CameraPitch;
transform.Rotate(Vector3.up * MouseDelta.x * Sensitivity);
}
private void Moving()
{
Vector2 InputDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
InputDirection.Normalize();
Vector3 Velosity = transform.forward * InputDirection.y + transform.right * InputDirection.x;
controller.Move(Velosity * Time.deltaTime); // CharacterController не содержит определение Move
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question