Example #1
0
    public void Move(Collider col)
    {
        //Translate
        Vector3 moveVector = col.transform.position - pos;
        //Rotate
        Quaternion relative       = Quaternion.Inverse(quat) * col.transform.rotation;
        Vector3    groundingpoint = player.transform.position - new Vector3(0, player.capsule.height / 2 - player.capsule.radius, 0) - normal.normalized * player.capsule.radius - pos;
        Vector3    newNormal      = relative * normal;
        Vector3    trans          = (relative * (groundingpoint)) + newNormal.normalized * player.capsule.radius + new Vector3(0, player.capsule.height / 2 - player.capsule.radius, 0) + pos;

        moveVector += trans - player.transform.position;
        player.ForceMove(moveVector);
    }