Beispiel #1
0
 void Update()
 {
     if (InputManager.GetButtonDown("Use"))
     {
         InteractObj tempCast = CastObj();
         if (tempCast != null && tempCast.CanDirectInteraction)
         {
             tempCast.OnInteractObject();
             print("YeeeBOY");
         }
         else
         {
             print("FUCKOFF");
         }
     }
 }
Beispiel #2
0
 void Start()
 {
     // 如果需要跟随其他物体
     if (followOther != null)
     {
         followOtherOffset = this.transform.position - followOther.transform.position;
     }
     if (overrideInteactTime)
     {
         InteractObj = GetComponent <InteractObj>();
         InteractObj.isTimeOverrided = true;
     }
     childrenObj = this.GetComponentsInChildren <Transform>();
     // 将所有的mask设置为default
     ChangeLayerMask("Default");
 }
Beispiel #3
0
    private InteractObj CastObj()
    {
        Vector3    rayOrigin    = mainCam.ViewportToWorldPoint(new Vector2(0.5f, 0.5f));
        Vector3    rayDirection = mainCam.transform.forward * 1.5f;
        RaycastHit rayHit       = new RaycastHit();

        if (Physics.Raycast(rayOrigin, rayDirection, out rayHit, 2f))
        {
            InteractObj tempObj = rayHit.collider.GetComponent <InteractObj>();
            if (tempObj != null)
            {
                return(tempObj);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }
Beispiel #4
0
 void Start()
 {
     interactObj = GetComponent <InteractObj>();
     offset      = this.transform.position - TargetObj.transform.position;
 }