How to get the average value from multiple line traces

Good evening!

I’m currently attempting to create a procedural ambience system using Wwise. My goal is to have multiple line traces which I can use to determine the amount of space around the player and roughly calculate the size of the room the player is in and use this to drive an Real Time Parameter Control in Wwise which I can use to drive/change the ambience/Reverbs depending on the size of the room.

The attached screenshot is the trace which is working successfully and if I attach a print string to the distance on the Break Hit result it gives me the results from each trace (4 values in total). I however need a single value to drive the RTPC, So I was thinking that it would be best to get an average of the 4 values and send that to WWise.

Can anyone help point me in the direction of how to calculate an average value of these results and add it to those script? Any help would be very much appreciated!

Thanks in advance.

Rich

In your loop, put the distances in an array

and then afterwards

This worked great! Thank you so much for your help!

1 Like

i think i could get what i need by just adding together the distances and inverting that number, but whenever i add it just keeps adding indefinitely as it doesn’t know how many indexes are in each sum

i can see the individual distance hits, but can’t get them separately or add them properly

I don’t think you need the multi-line trace, unless you want to trace through objects ( that’s what it’s for )?

A normal LT is fine. You just have to do them in a spherical pattern, as in these articles :slight_smile:

Regarding counting the misses and hits, you can just total in two integers.

1 Like

thanks for that,

regarding post2 - if anyone knows why the Average variable constantly slowly fluctuates even though the 4 hit distances update immediately I’d be super grateful!

also when i print array to screen it just keeps increasing

If the array keeps getting larger, then just put a ‘clear’ back here somewhere