UPDATE to what i tried and did so far:
From the NAVI (Droid) i removed the box collider component and added two things:
This is the Control script:
using UnityEngine;
using System.Collections;
public class Control : MonoBehaviour
{
public float rotationDamping = 20f;
public float speed = 10f;
public int gravity = 0;
public Animator animator;
float verticalVel; // Used for continuing momentum while in air
CharacterController controller;
void Start()
{
controller = (CharacterController)GetComponent(typeof(CharacterController));
}
float UpdateMovement()
{
// Movement
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 inputVec = new Vector3(x, 0, z);
inputVec *= speed;
controller.Move((inputVec + Vector3.up * -gravity + new Vector3(0, verticalVel, 0)) * Time.deltaTime);
// Rotation
if (inputVec != Vector3.zero)
transform.rotation = Quaternion.Slerp(transform.rotation,
Quaternion.LookRotation(inputVec),
Time.deltaTime * rotationDamping);
return inputVec.magnitude;
}
void AnimationControl ()
{
if(Input.GetKey("a") || Input.GetKey("s") || Input.GetKey("d") || Input.GetKey("w"))
{
animator.SetBool ("Moving" , true);
}
else
{
animator.SetBool ("Moving" , false);
}
if(Input.GetKey("space"))
{
animator.SetBool ("Angry" , true);
}
else
{
animator.SetBool ("Angry" , false);
}
if(Input.GetKey("mouse 0"))
{
animator.SetBool ("Scared" , true);
}
else
{
animator.SetBool ("Scared" , false);
}
}
void Update()
{
UpdateMovement();
AnimationControl();
if ( controller.isGrounded )
verticalVel = 0f;// Remove any persistent velocity after landing
}
}
Now when i move the character close to a door or wall also the NAVI(Droid) stop and is not moving through the door or wall and this is fine. But now i have another problem. If i will keep moving to the door or wall it looks like the character is moving over/on the NAVI Droid.
The Navi droid is not changing position.
In this screenshot is how it looks like when i moved close to the door the collider on the door and the NAVI Droid are working and the navi droid can’t move through the door:
In this screenshot you can see what is happened when i kept moving the character to the door. On the top screen view the NAVI droid is in the same position but on the Game View on the bottom it seems like the character is moving over/on the NAVI droid.
And if i will keep moving to the door the character will not move but the droid looks like pushed back or the character will keep moving over the droid.
I tried to add also Rigidbody to the NAVI Droid but it didn’t change much and if i don’t set the Is Kinematic to true i will get error: Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5.
But anyway the Rigidbody didn’t help much.
And this is a small shot video clip i recorded showing the problem.
You can see the problem in the bottom game view window on the left:
The problem start from second 20: