I’m in the process of converting my Unity game into UE4. It’s a marble game with all sorts of powerups and levels inspired by the Marble Blast franchise. I am having a problem with the collision hit sound. Right now, I have a blueprint that plays the hit sound on collision with the ground. It works all fine, but I want the volume to change based on how hard the collision is. I CANNOT just look at the current velocity of the marble and change the volume from that. What if the marble is moving fast, but hits the ground softly? That will make it play the sound full volume and I do not want that.
Unity has a very useful feature that is Collision.relativeVelocity.
From the collision it gets the RELATIVE velocity between the two objects colliding. This is exactly what I wanted and it worked perfectly. However, I cannot see anything like this in UE4 and it’s kinda disappointing.
Have I missed it? I didn’t see anything like that in the Event Hit node. Even with all of the structs split. Since UE4 doesn’t appear to have this functionality, what other ways could I get a similar result? What I’m thinking is finding the g-force, but I have no idea how I can do that.
EDIT: Ok, I figured out how to calculate g-force, but it is kind of glitchy and somewhat gets what i want.
Is the ground floor moving? Seems the only way a ball at high speed receives a low impulse, which i guess is the one you base the volume on?
In that case you could when the ball hits the plane, get the velocity of the moving plane, and compare it to that of the ball.
I imagine something like ((Ball +/- Plane) / Ball ). Gives 1 on a non moving plane, higher than 1 if the plane moves towards the ball, and less than 1 if moving away. Then you could plug this ratio directly into the volume. If there are different surface types, you could give each surfaceBP a multiplier, get that upon impact, and plug it into the equation.
Hope i make some kind of sense, and that it could also be useful
No the ground is not moving. This isn’t what I’m looking for. I’m looking to find the equivalent to Unity’s Collision.relativeVelocity. I want the velocity for the marble relative to the collision surface. I guess with some kind of vector math by getting the surface normal direction and try to get the velocity in that direction will work, but I’m not a big math person and i cannot find any examples.
If the surface isn’t moving then the relative velocity of the collision IS the full velocity of the ball. (Ball velocity - collider velocity = relative velocity)
If the surface being collided with is moving then it’s likely an actor, in which case you can simply get the difference in velocities by the above equation, referencing the actor being collided in the onHit event. (IE Velocity-otherActor.velocity = relative velocity) then you can get the length of that vector and scale it as needed to get a valid value for your volume multiplier.
Also if you’re looking to have different volumes or types of hit sound depending on what material you’re hitting, look in to Physical materials. They’re for just that sort of thing.
Ok, I’m gonna try to explain this differently. I want to get the velocity of the marble in the direction of the normal of the surface collided. This is, at least, what the Collision.relativeVelocity does in Unity3D.