Mail.ru
Почта
Мой Мир
Одноклассники
ВКонтакте
Игры
Знакомства
Новости
Календарь
Облако
Заметки
Все проекты
Все проекты
выход
Регистрация
Вход
Категории
Все вопросы проекта
Компьютеры, Интернет
Темы для взрослых
Авто, Мото
Красота и Здоровье
Товары и Услуги
Бизнес, Финансы
Наука, Техника, Языки
Философия, Непознанное
Города и Страны
Образование
Фотография, Видеосъемка
Гороскопы, Магия, Гадания
Общество, Политика, СМИ
Юридическая консультация
Досуг, Развлечения
Путешествия, Туризм
Юмор
Еда, Кулинария
Работа, Карьера
О проектах Mail
Животные, Растения
Семья, Дом, Дети
Другое
Знакомства, Любовь, Отношения
Спорт
Золотой фонд
Искусство и Культура
Стиль, Мода, Звезды
Полный список
Спросить
Лидеры
Поиск по вопросам
Ответы Mail
Программирование
Android
C/C++
C#
iOS
Java
JavaScript
jQuery
SQL
Perl
PHP
Python
Веб-дизайн
Верстка, CSS, HTML, SVG
Системное администрирование
Другие языки и технологии
Вопросы - лидеры.
IntelliJ IDEA Как установить плагины?
1 ставка
Помогите сделать так, чтобы ссылка где есть файл .php в покет коде выводил не весь код, а только текст.
1 ставка
Вывод информации о дисках в ассемблер
1 ставка
Вывод инфы о подключенных дисках в Ассемблер
1 ставка
Активация аккаунта на ps4 с прошивкой 11.00
1 ставка
Лидеры категории
Лена-пена
Искусственный Интеллект
М.И.
Искусственный Интеллект
Y.Nine
Искусственный Интеллект
•••
Что делать с такой ошибка в unity?
Nikita Smirnov
Ученик
(128), на голосовании
8 месяцев назад
код: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
//классическое перемещение игрока
public float movespeed;
public float sensitivity;
public float gravity;
private float mouseX;
private float mouseY;
private float vertical;
private float horizontal;
public Vector2 clampangle;
private Vector3 Velocity;
private Vector2 angle;
public Transform cameraTransform; //камера внутри игрока
private CharacterController charactercontroller;
private void Start()
{
charactercontroller = GetComponent<CharacterController>();
Cursor.LockState - CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
vertical = Input.GetAxis("Vertical");
horizontal = Input.GetAxis("Horizontal");
Vector3 playerMovementInput = new Vector3(horizontal, 0.0f, vertical);
Vector3 moveVector = transform.TransformDirection(playerMovementInput);
if (Input.GetAxis("Vertical") > 0 || Input.GetAxis("Vertical") < 0 || Input.GetAxis("Horizontal") > 0 || Input.GetAxis("Horizontal") < 0)
{
if (Input.GetKey(KeyCode.LeftShift) && Input.GetAxis("Vertical") > 0)
{
movespeed = 6;
//бежит
}
else
{
movespeed = 2f;
//идет
}
}
else
{
//стоит
}
if (charactercontroller.isGrounded)
{
Velocity.y = -1f;
}
else
{
Velocity.y -= gravity * Time.deltaTime;
}
charactercontroller.Move(moveVector * movespeed * Time.deltaTime);
charactercontroller.Move(Velocity * Time.deltaTime);
mouseX = Input.GetAxis("Mouse X");
mouseY = Input.GetAxis("Mouse Y");
angle.x -= mouseY * sensitivity;
angle.y -= mouseX * -sensitivity;
angle.x = Mathf.Clamp(angle.x, -clampangle.x, clampangle.y);
Quaternion rotation = Quaternion.Euler(angle.x, angle.y, 0.0f);
Quaternion rotationTwo = Quaternion.Euler(0.0f, angle.y, 0.0f);
transform.rotation = rotationTwo;
cameraTransform.rotation = rotation;
}
}
Голосование за лучший ответ
Иван Сигаев
Искусственный Интеллект
(153319)
9 месяцев назад
Попробуй
Cursor.lockState
PS: что-то подсказывает мне, что не поможет, там не одна ошибка "кАпирования"
Похожие вопросы
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
//классическое перемещение игрока
public float movespeed;
public float sensitivity;
public float gravity;
private float mouseX;
private float mouseY;
private float vertical;
private float horizontal;
public Vector2 clampangle;
private Vector3 Velocity;
private Vector2 angle;
public Transform cameraTransform; //камера внутри игрока
private CharacterController charactercontroller;
private void Start()
{
charactercontroller = GetComponent<CharacterController>();
Cursor.LockState - CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
vertical = Input.GetAxis("Vertical");
horizontal = Input.GetAxis("Horizontal");
Vector3 playerMovementInput = new Vector3(horizontal, 0.0f, vertical);
Vector3 moveVector = transform.TransformDirection(playerMovementInput);
if (Input.GetAxis("Vertical") > 0 || Input.GetAxis("Vertical") < 0 || Input.GetAxis("Horizontal") > 0 || Input.GetAxis("Horizontal") < 0)
{
if (Input.GetKey(KeyCode.LeftShift) && Input.GetAxis("Vertical") > 0)
{
movespeed = 6;
//бежит
}
else
{
movespeed = 2f;
//идет
}
}
else
{
//стоит
}
if (charactercontroller.isGrounded)
{
Velocity.y = -1f;
}
else
{
Velocity.y -= gravity * Time.deltaTime;
}
charactercontroller.Move(moveVector * movespeed * Time.deltaTime);
charactercontroller.Move(Velocity * Time.deltaTime);
mouseX = Input.GetAxis("Mouse X");
mouseY = Input.GetAxis("Mouse Y");
angle.x -= mouseY * sensitivity;
angle.y -= mouseX * -sensitivity;
angle.x = Mathf.Clamp(angle.x, -clampangle.x, clampangle.y);
Quaternion rotation = Quaternion.Euler(angle.x, angle.y, 0.0f);
Quaternion rotationTwo = Quaternion.Euler(0.0f, angle.y, 0.0f);
transform.rotation = rotationTwo;
cameraTransform.rotation = rotation;
}
}