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"

Line trace to change material then revert back

I'm struggling to get the original material and then being able to change it after I stop looking at the object. Thanks.

Product Version: UE 4.22
Tags:
more ▼

asked May 19 '19 at 02:06 PM in Blueprint Scripting

avatar image

LongFunnyName
1 1 1

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

3 answers: sort voted first

You can do the line trace from your view point to check if it's hit the object and just set the required material if state is changed (you can store the "looking at" state somehow – either in a bool variable if you have a single object to check or the actor's reference to check if it's the same object).

more ▼

answered May 19 '19 at 03:04 PM

avatar image

norlin
435 11 18 25

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

Hello!

  1. Create SightInteraction_Interface add SightState_Function in it with Bool input variable IsPlayerLookingAtMe? alt text

  2. Create SightReaction_BP add StaticMesh_Component and in ClassDetails implement SightInteraction_Interface. Now implement SightState_Event to drive Material of your StaticMesh_Component.alt text

  3. In FirstPersonCharacter_BP implement TraceByChannel to check what Actor you see currently You need DefaultSightActor and NewSightActor variables. Set your Trace distance factor. Now call SightState_Event alternating bool IsPlayerLookingAtMe? to change Material (actually do any things) alt text

  4. You can check if Actor does implement interface before send InterfaceMessage at all... and check if IsValid? and etc... GLHF

interface.png (72.6 kB)
fpcharacter-bp.png (382.9 kB)
more ▼

answered May 19 '19 at 05:10 PM

avatar image

TVinforest
459 15 13 23

avatar image LongFunnyName May 19 '19 at 11:05 PM

Hey thanks but I'm having trouble with your answer, it doesn't seem to change material at all. Not sure what to do.

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

depending what you're doing, you may not even need to linetrace or use a blueprint. you have access to the camera direction in the material so you can just change the parameters of the material when you're looking at it.

alt text

Edit: object position may be better than using actor position.

more ▼

answered May 19 '19 at 10:02 PM

avatar image

IndieGameCove
1.3k 9 4 10

avatar image LongFunnyName May 19 '19 at 11:19 PM

Thank you, this worked but I don't think I'd be able to utilise it for the my required function.

(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