Unity3D, C# помогите пожалуйста настроить взаимодействие персонажа с объектами из blender
Сейчас персонаж (тоже из blender) проходит сквозь объекты, а нужно чтобы он останавливался при взаимодействии. При чём с некоторыми объектами можно взаимодействовать. Вот код основного персонажа:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public LayerMask groundMask;
public Transform groundCheck;
public float speed = 5f;
public float gravity = -19.6f;
public float groundDistance = 0.01f;
public float jumpHeight = 1f;
Vector3 velocity;
bool isGrounded;
void Start()
{
}
// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if (isGrounded == true && velocity.y < 0)
{
velocity.y = -2f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
if (Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
if (Input.GetKey("c"))
{
controller.height = 1f;
}
else
{
controller.height = 2f;
}
if (Input.GetKey("left shift"))
{
speed = 9f;
}
else
{
speed = 5f;
}
}
}
Может дело не в коде, вот скриншот настроек:
