void ResetTarget() { //timerToShot = 0f; if (targetLoadShot) { Destroy(targetLoadShot); } RaycastHit2D ray = Physics2D.Raycast(transform.position, Vector2.right, distanceToRight, rayToCloseEnemy); if (ray.collider && (moveState != MoveState.OnChangeUp || moveState != MoveState.OnChangeDown)) { var movableObject = ray.collider.GetComponent <MovableObject>(); if (movableObject == null) { return; } if (movableObject.transform.position.x - transform.position.x <= 0) { movableObject.gameObject.layer = layerDefault; target = null; return; } target = movableObject; timeToShot = movableObject.myParams.strength.val; targetLoadShot = Instantiate(loadShot, target.transform); } else { target = null; timeToShot = defaultTimeToShot; playerAnimatorController.SetShotting(false); } }