Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Physics.CheckSphere

public static function CheckSphere(position: Vector3, radius: float, layerMask: int = DefaultRaycastLayers): bool;

Description

Returns true if there are any colliders overlapping the sphere defined by position and radius in world coordinates.

	var sphereRadius: float;
	
	function WarningNoise() {
		// Play a noise if an object is nearby.
		if (Physics.CheckSphere(transform.position, sphereRadius)) {
			audio.Play();
		}
	}