using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float Speed = 6f;
Vector3 _movement;
Animator _anim;
Rigidbody _playerRigidBody;
int _floorMask;
float CamRayLength = 100f;
void Start()
{
_floorMask = LayerMask.GetMask("Floor");
_anim = GetComponent<Animator>();
_playerRigidBody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Move(h, v);
Turning();
}
void Move(float h, float v)
{
_movement.Set(h, 0f, v);
_movement = _movement.normalized * Speed * Time.deltaTime;
_playerRigidBody.MovePosition(transform.position + _movement);
}
void Turning()
{
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit floorHit;
if (Physics.Raycast(camRay, out floorHit, CamRayLength, _floorMask))
{
Vector3 playerToMouse = floorHit.point - transform.position;
playerToMouse.y = 0;
Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
_playerRigidBody.MoveRotation(newRotation);
}
}
// Update is called once per frame
void Update () {
}
}
А вот сама ошибка:
NullReferenceException: (null)
UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs) (at C:/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:74)
UnityEditor.AssetImporterInspector.GetSerializedObjectInternal () (at C:/buildslave/unity/build/Editor/Mono/ImportSettings/AssetImporterInspector.cs:57)
UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:147)
UnityEditor.ModelImporterClipEditor.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/ImportSettings/ModelImporterClipEditor.cs:139)
Код полностью работает, выполняет все свои функции, а все нужные объекты присутствуют на игроке
Или ошибка связана с импортированной моделькой игрока?