public void Use() { //Debug.Log("Attack"); if (wpn != null && !player.locked) { if (wpn.type == 2 && !wpn.isSwinging && player.GetComponent <Inventory>().HasItem("arrow")) { ((Bow)wpn).Use(); player.GetComponent <Inventory>().RemoveSingleItem("arrow"); } else { wpn.Use(); } } }
/// <summary> /// performs a number of tests to see if the player can currently teleport /// and whether the pointer object is currently pointing at a position that /// can be teleported to. if so, returns that position. if not, returns /// 'NO_DESTINATION' /// </summary> protected virtual Vector3 GetDestination() { // abort if player is dead if (FPPlayer.Dead.Active) { return(NO_DESTINATION); } // abort if player is interacting if (FPPlayer.Interactable.Get() != null) { return(NO_DESTINATION); } // abort if player can interact if (VRCrosshair != null && VRCrosshair.CanInteract) { m_NextAllowedTeleportTime = (Time.time + MinTeleportInterval); return(NO_DESTINATION); } // get where we're pointed at RaycastHit hit; Physics.Linecast( DirectionPointer.position, ((DirectionPointer.position) + (DirectionPointer.forward * 100)), out hit, ~((1 << vp_Layer.LocalPlayer) | (1 << vp_Layer.Debris) | (1 << vp_Layer.IgnoreRaycast) | (1 << vp_Layer.IgnoreBullets) | (1 << vp_Layer.Trigger) | (1 << vp_Layer.Water) | (1 << vp_Layer.Pickup))); // abort if pointing at nothing if (hit.collider == null) { return(NO_DESTINATION); } // abort if pointing at a trigger if (hit.collider.isTrigger) { return(NO_DESTINATION); } // abort if too steep float steepness = Vector3.Angle(Vector3.up, hit.normal); if (steepness > FPPlayer.GetComponent <CharacterController>().slopeLimit) { return(NO_DESTINATION); } // abort if too far if (Vector3.Distance(vp_3DUtility.HorizontalVector(FPPlayer.transform.position), vp_3DUtility.HorizontalVector(hit.point)) > MaxTeleportDistance) { return(NO_DESTINATION); } // abort if path is blocked float distance = Mathf.Max(1.0f, Vector3.Distance(vp_3DUtility.HorizontalVector(FPPlayer.transform.position), vp_3DUtility.HorizontalVector(hit.point))); Vector3 point1 = FPPlayer.transform.position + (Vector3.up * (FPPlayer.Height.Get() * 0.5f)); Vector3 point2 = point1 + Vector3.up * (FPPlayer.Height.Get() - (FPPlayer.Radius.Get() * 2)); if (Physics.CapsuleCast( point1, point2, FPPlayer.Radius.Get(), FPController.transform.forward, distance, vp_Layer.Mask.PhysicsBlockers)) { if (!(hit.collider is TerrainCollider) && (hit.transform.gameObject.layer != vp_Layer.Pickup) && (!hit.collider.isTrigger) ) // non-steep terrain, triggers and pickups are always passable { return(NO_DESTINATION); } } return(hit.point); }