using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BishScript : MonoBehaviour {

    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        
    }

    void OnHitEnter(Collision other) {
        if (other.contacts != null) {
            if (other.gameObject.tag == "bed") return;
            if (gameObject.tag == "bed") return;
            GetComponent<Rigidbody>().useGravity = true;

            /* impulse and relativeVelocity does not work, 
               movement is controlled by animation(set pos/rotation by frame), not rigidbody(force)  */
            //Debug.Log(other.contacts.Length);
            //Debug.Log(other.relativeVelocity);
            //Debug.Log(other.impulse);
            //Debug.Log(other.impulse);
            Debug.DrawRay(transform.position, other.impulse, Color.green, 5);
            foreach (var c in other.contacts) {
                if (c.otherCollider.tag == "bed") continue;
                if (c.thisCollider.tag == "bed") continue;
                //Debug.Log (c.otherCollider.name) continue;
                //Debug.Log (c.thisCollide//r.tag == "bed") continue;
                //var c = other.contacts[0];
                Debug.Log(c.normal);
                Debug.DrawRay(c.point, c.normal, Color.red, 3);
                //Debug.Log(other.contacts[0].point);
            }
        }
    }

    void OnHitExit(Collision other) {

    }

    void OnTriggerEnter(Collider other) {
        Debug.Log("triggerEnter");
        /*
        Script error: OnTriggerEnter
        This message parameter has to be of type: Collider
        The message will be ignored.
        */
        //OnHitEnter(other);
    }

    void OnTriggerExit(Collider other) {

    }

    void OnCollisionEnter(Collision other) {
        Debug.Log("collision enter");

        OnHitEnter(other);
    }

    void OnCollisionExit(Collision other) {

    }

    void OnGUI() {

    }

}
