Starting a counter if player is on a physical material

Hi All

So for my dissertation project I need to make the game start a counter when a player leaves a gravel track. In this script I am trying to compare the output of LineTraceByChannel to a physical material and if it not equal, then add +1 to an integer thus working like a counter.

This is not working properly as it’s counting upwards without the regards whether I am on gravel or not. Please help

Thank you very much!

Hey,

What are the start and end vectors of your line trace? Are you sure you are shooting the line where you want to shoot?

why are you not pulling off “out hit phys mat”. This way you are always hitting something else and due to the current setup it keeps incrementing the integer.

Can you show the rest of the graph?

Now you need to check the surface type with “==” to see if it equals gravel and branch it. If it is true increment “OnGround” if not, leave empty.

Currently you are not checking anything so it keeps incrementing the integer.

For debugging purposes I got it to print out the physical material it is hitting and it just shows up as default even though I have them properly set and I have footstep sounds implemented aswell depending on physical materials.

Here is an image of the whole script. It starts at the first person player and end straight down.

Yes, thats what I did in the original script but through the last image I uploaded I saw that the code recognises everything only as default material, any idea why?

Are you sure you have assigned the physical material to the material? You can do that in the material editor.

Yes. My footsteps are working perfectly, I don’t understand why is this not working…

  1. Have you applied the material (with the physical material on it) to the ground mesh placed in your scene?
  2. Pull off of out hit actor from your line trace and double check if you are hitting the ground actor.
  3. You could also use debug draw on the line trace and see if the line actually intersects the object you want, maybe you are colliding with something else.

Where and how do you actually implement the playing of the foodstep sound? I do not see anything following from your line trace