Hello I read the Docs about OverlapCricle and they say that I can get an array from all the collision Objects.
In my game this is always only one object in the array. How the question is, how do I get exits to the array?
What I tried
public void PickUpBox(InputAction.CallbackContext context) {
if (context.performed && currentBox == null && !hasBox) {
if (Physics2D.OverlapCircle(directionPoint.position,0.2f, boxLayer)) {
Collider2D resulteBox = Physics2D.OverlapCircle(directionPoint.position,0.2f, boxLayer);
currentBox = resulteBox.gameObject;
boxScrip = currentBox.GetComponent<BoxScript>();
But this doesn’t seem to work. I don’t get an error, but I also can’t call the function below
public void ProcessBoxPosition() {
if (boxScrip != null) {
boxScrip.pickUp(new Vector3(lastPositionPoint.position.x, lastPositionPoint.position.y, lastPositionPoint.position.z));
Debug.Log("PICK UP WAS CALLED");
}
}
Link for the Docs: Unity - Scripting API: Physics2D.OverlapCircle