Как исправить ошибку в коде с Quaternion в Unity 2.4.5?
Делал код чтобы персонаж ходил.
Написал код "Move":
using UnityEngine;
[RequireComponent (typeof(Rigidbody))]
public class go : MonoBehaviour
{
private Camera cam;
private Rigidbody rb;
private Vector3 velocity = Vector3.zero;
private Vector3 rotation = Vector3.zero;
private Vector3 rotationCamera = Vector3.zero;
void Start()
{
rb = GetComponent <Rigidbody> ();
cam = Camera.main;
}
public void Move (Vector3 _velocity)
{
velocity = _velocity;
}
public void Rotate(Vector3 _rotation)
{
rotation = _rotation;
}
public void RotateCam(Vector3 _rotationCam)
{
rotationCamera = _rotationCam;
}
void FixedUpdate()
{
PerformMove();
PerformRotate();
}
void PerformMove()
{
if (velocity != Vector3.zero)
{
rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
}
}
void PerformRotate() {
rb.MoveRotation (rb.rotation + Quaternion.Euler (rotation));
if (cam != null) {
cam.transform.Rotate(-rotationCamera);
}
}
}
И ище один "Control":
using UnityEngine;
[RequireComponent(typeof(go))]
public class control : MonoBehaviour {
[SerializeField]
private float speed = 5f;
[SerializeField]
private float lookspeed = 3f;
private go motor;
void Start()
{
motor = GetComponent<go>();
}
void Update() {
float xMov = Input.GetAxisRaw("Horizontal");
float zMov = Input.GetAxisRaw("Vertical");
Vector3 movHor = transform.right * xMov;
Vector3 movVer = transform.forward * zMov;
Vector3 velocity = (movHor * movVer).normalized * speed;
motor.Move(velocity);
float yRot = Input.GetAxis ("Mouse X");
Vector3 rotation = new Vector3 (of, yRot, of) * lookspeed;
motor.Rotate(rotation);
float xRot = Input.GetAxis ("Mouse Y");
Vector3 camrotation = new Vector3 (xRot, of, of) * lookpeed;
motor.Rotatecam(cam_rotation);
}
}
Добавил к объекту, запустил.
Ошибка: Operator '+' cannot be applied to operands of type 'Quaternion' and 'Quaternion'.
Как исправить?