Troubleshooting Balloon Physics in Unity

I’ve been getting more used to using Unity and developing a nice workflow with the Meta Quest 3. I am continuing to build a really simple game for now called “Keepy Uppy”, which is a balloon keep up game. My goal has been to learn more about how to develop in Mixed Reality for the Meta Quest 3.

One of my biggest challenges right now is learning how to mimic interaction with hands and the balloon. I have a rigidbody on my hands and I’m trying to also use a script to handle the force applied. It’s not been easy figuring out how to get it to work with my hands.

Here is the updated script for my sphere interaction:

Sphere Interaction Script


using UnityEngine;
using UnityEngine.SceneManagement;

public class SphereInteraction : MonoBehaviour
{
    public float forceMultiplier = 5f; // Adjust this to change how hard the sphere is hit
    public ScoreManager scoreManager; // Reference to the ScoreManager script

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "GameController")
        {
            Rigidbody rb = GetComponent();
            Vector3 forceDirection = collision.contacts\[0\].point - transform.position;
            forceDirection = -forceDirection.normalized;
            Debug.Log("Applying force: " + forceDirection * forceMultiplier);
            rb.AddForce(forceDirection * forceMultiplier, ForceMode.Impulse);

            // Update the score
            if (scoreManager != null)
            {
                scoreManager.AddScore(1); // Assuming AddScore(1) increases the score by 1
            }

            // Log the new position
            Debug.Log("New Position: " + transform.position);
        }
    }
}
</code></pre>