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"

Toggle object material on trace hit

Hello all,

First, a brief explanation of the game I'm trying to make.

I'm creating a fps puzzle game that involves picking up blocks/other shapes and using them to unlock puzzles. Part of the puzzle system involves the objects having different weights. I currently have it so that I can pick up objects, and the speed at which I can move them around slows down depending on their mass. They also slow down play movement speed depending on mass.

I'm currently trying to add functionality to my game that would make it so when I look at an object, it turns transparent, and displays its mass in the center of it, and when I'm not looking at the object, it sets itself back to its default material, basically a first-person "mouse-over".

I'm trying to do this via trace from my player camera. I have no problems setting an objects material when the trace hits it, but setting it back to default is proving extremely challenging. I've tried using a blueprint interface, and this DOES work, however, since I have to call the exact blueprint that I want to change, its not a very flexible system. This would actually be my ideal method, so if there's some way for me to dynamically get the blueprint that my trace hit, and then send an event to that specific blueprint, it would be awesome... but as far as I can tell, there's no way to do that.

The other option I tried was to capture the objects material when the trace first hits it, and then set it back to that after the "mouse-over" is complete. The problem is that once my trace hits it, its material changes to the transparent version, and then it just captures that material rather than the default one and the object gets stuck in transparent mode.

Does anyone have any suggestions on how I might solve this? I'm sure there's some tricky way to achieve everything I want, but I'm fairly new to scripting in general, so this is currently evading me.

Any help would be greatly appreciated!

Product Version: Not Selected
Tags:
more ▼

asked Mar 28 '14 at 10:37 AM in Blueprint Scripting

avatar image

venain
38 5 12 9

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

1 answer: sort voted first

Had a similar problem. In the end I captured the original material in a variable before changing it the first time.

Then I created a timer which would reset the material after 0.1 s which gets cleared each time, the hit function is called. So when there was no hit for > 0.1 s, the object's original material was applied again.

It's clunky, but it works.

more ▼

answered Apr 20 '15 at 10:00 AM

avatar image

spyro
1.7k 106 117 233

(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