Example #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        RaycastHit hit;

        Vector3 direction = transform.TransformDirection(Vector3.forward);

        Debug.DrawRay(transform.position, direction, Color.red);

        if (Input.GetKey(KeyCode.F) && Physics.Raycast(transform.position, direction, out hit, 10))
        {
            Usable usable = hit.transform.GetComponent <Usable>();
            if (usable != null)
            {
                usable.beingUsed();
            }
        }
    }