Answer the question
In order to leave comments, you need to log in
How to fix such an error with a jump?
Hello, please help me with this error. Can't find a solution
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (Physics.Raycast(transform.position, Vector3.down, GetComponent<BoxCollider>().size.y / 2 + 0.4f))
{
Quaternion rot = transform.rotation;
rot.z = Mathf.Round(rot.z / 90) * 90;
transform.position = rot;
if (Input.GetMouseButtonDown(0)) {
rb.velocity = Vector3.zero;
rb.AddForce(Vector2.up * 55000);
}
}
else {
transform.Rotate(Vector3.back * 5f);
}
}
}
Answer the question
In order to leave comments, you need to log in
It seems that you wanted to write
Quaternion rot = transform.rotation;
rot.z = Mathf.Round(rot.z / 90) * 90;
transform.position = rot; // Взяли квартернион из rotation, и пытаемся изменить position...
Quaternion rot = transform.rotation;
rot.z = Mathf.Round(rot.z / 90) * 90;
transform.rotation = rot;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question