Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to get the force from a ball hitting a wall?

Discussion in 'Scripting' started by midu77, Mar 14, 2021.

  1. midu77

    midu77

    Joined:
    Sep 25, 2018
    Posts:
    4
    I need to get the „force“ from a ball that hits a wall when bouncing around in a room (to control the intensity of a hit sound in Wwise via RTPC). Because it’s for a simulation in VR it has to be pretty accurate.

    At the moment im using velocity.magnitude from the Rigidbody of the ball.
    Screenshot.PNG
    This is accurate as long as the ball hits the wall in a 90° angle. When the ball hits in a much smaller angle (say only streaking the wall) but with high speed, velocity.magnitude is to big compared to the actual impact of the ball.
    Skizze.jpeg
    Any idea how to solve this?
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,196
    You can look at the Collision object to see details about the collision. See here.
     
    midu77 likes this.
  3. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    midu77 likes this.
  4. midu77

    midu77

    Joined:
    Sep 25, 2018
    Posts:
    4
    A big thank you to both of you for the ultra fast reply! collision.impulse.magnitude is exactly what I was looking for!
     
    Last edited: Apr 8, 2021