Планец в игре «Разбивание кирпичей» проходит сквозь стены. Я много раз пытался это исправить, но безуспешно. BoxCollider и RigidBody выглядят нормально. Мой код находится внизу, и я загрузил видео на YouTube, чтобы лучше продемонстрировать ошибку.
Мой код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rightcontroller : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent();
}
void FixedUpdate()
{
bool RightArrow = Input.GetKey(KeyCode.RightArrow);
bool LeftArrow = Input.GetKey(KeyCode.LeftArrow);
if (RightArrow)
{
Vector3 tempVect = new Vector3(0, 0, 1);
tempVect = tempVect.normalized * speed * Time.deltaTime;
rb.MovePosition(transform.position + tempVect);
}
if (LeftArrow)
{
Vector3 tempVect = new Vector3(0, 0, -1);
tempVect = tempVect.normalized * speed * Time.deltaTime;
rb.MovePosition(transform.position + tempVect);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/720 ... i-fix-this