Hi guys,
I’m currently developing a tactical RPG and I’ve set walls in order to prevent the NPC to move outside the game’s area. However, the NPC is moving through the walls. He has a rigidbody, a capsule collider attached to him and he is triggered. Besides, the use gravity option and is kinematic are marked as well. The walls have a rigidbody and a box collider. They are not triggered.
I’m using this function to move the NPC. I call it in FixedUpdate:
public void MoveNPC()
{
targetPosition.y = 1.4f;
targetPosition.x = this.transform.position.x;
targetPosition.z = this.transform.position.z - movMax;
myRigidbody.MovePosition(Vector3.MoveTowards(transform.position, targetPosition, velocity));
IsMoving = true;
}
The NPC still walks through the walls. How could I fix it?