x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!alt text

Product Version: UE 4.17
Tags:
gravelcounter.png (142.6 kB)
more ▼

asked Apr 11 '18 at 01:49 PM in Blueprint Scripting

avatar image

ernijsyoyo
3 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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?

more ▼

answered Apr 11 '18 at 02:01 PM

avatar image

BreakMaker
242 5 11 17

avatar image ernijsyoyo Apr 11 '18 at 02:09 PM

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.alt text

gravelcounter.png (153.4 kB)
avatar image BreakMaker Apr 11 '18 at 02:16 PM

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.

avatar image ernijsyoyo Apr 11 '18 at 02:17 PM

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?

avatar image BreakMaker Apr 11 '18 at 02:24 PM

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

avatar image ernijsyoyo Apr 11 '18 at 02:47 PM

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

avatar image BreakMaker Apr 11 '18 at 02:54 PM
  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.

avatar image BreakMaker Apr 11 '18 at 03:26 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question