asset integration 50%

This commit is contained in:
2026-03-29 02:27:55 +05:30
parent 3108262326
commit b8ce9120d5
1691 changed files with 1192616 additions and 262 deletions
+30 -1
View File
@@ -9,6 +9,8 @@ public class Ball : MonoBehaviour
public float wallStuckFixForce = 1f;
public float maxWallStuckVelocity = 5f;
public LayerMask wallLayerMask;
public float distToGoal;
public float nearGoalThreshold = 2.5f;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
@@ -34,7 +36,23 @@ public class Ball : MonoBehaviour
void Update()
{
WallDetection();
CheckNearGoal();
}
void CheckNearGoal(){
Goal[] goals = FindObjectsByType<Goal>(FindObjectsSortMode.None);
float closestDist = float.MaxValue;
foreach(Goal goal in goals){
float dist = Vector3.Distance(transform.position, goal.transform.position);
if(dist < closestDist){
closestDist = dist;
}
}
distToGoal = closestDist;
AudioManager.instance.SetIsBallNearGoal(distToGoal < nearGoalThreshold);
}
void OnCollisionEnter2D(Collision2D collision)
{
float otherSpeed = collision.relativeVelocity.magnitude;
@@ -67,7 +85,18 @@ public class Ball : MonoBehaviour
if (touchingB) {
rb.AddForce(Vector2.up *otherSpeed * wallStuckFixForce * velocityMult );
}
float maxVolSpeed =5f;
float vol = Mathf.Clamp01(otherSpeed / maxVolSpeed);
if(collision.collider.CompareTag("wall")){
AudioManager.instance.PlayWallHit(vol);
}
else if(collision.collider.CompareTag("Puck")){
AudioManager.instance.PlayBallHit(vol);
}
}
void WallDetection(){