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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Set Particle Parameter in Blueprint by Camera Distance

Hi, I like to set the particle opacity by camera distance in blueprint. I set up this blueprint so far, but it won't work.

There must be an error in the vector math of the cam distance formula, since when i make a literal float, i can see, the parameter connection works. 0 brings 0 opacity and 1 brings a lit particle ingame.

but when i connect the vector stuff, the particle stays at 0 opacity :( can you help me out?

alt text

Product Version: Not Selected
Tags:
more ▼

asked Oct 15 '14 at 09:50 PM in Blueprint Scripting

avatar image

[PB]Aphexx
309 25 27 42

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

1 answer: sort voted first

Use a subtraction instead of a division.

Let's say you have the camera and the actor at [1,1,1] and [3,3,3]. If you now subtract your camera from your actor you're left with [-2,-2,-2] which is a defined length and will provide you with the result you want.

However vector division is mathematically only possible if you provide special input and I'm not sure what unreal is doing inside of that node.

Here's a link to a discussion about vector division if you're interested.

Regardless of this though division only tells you how often the lower one fits into the upper part meaning you will never really get a useful number if you're searching for distance or anything like that.

more ▼

answered Oct 15 '14 at 10:44 PM

avatar image

Erasio
5.9k 291 86 293

avatar image [PB]Aphexx Oct 15 '14 at 11:14 PM

ah sure! my fault. it should have been a subtraction. or better: it was one, but i fiddled with the graph and deleted it once, and then somehow took division when i remodeled it. this is also the reason, why i saw my particle half the day, and then suddenly no more.

anyway, when i subtract it, the particle can be seen again, but it is always visible. but it should fade, when i come close to it.

which let me assume that the result is far beyond 1, or the resulting distance is mapped in a weird way to 0-1. do you have a clue how to normalize in a proper way? a simple clamp won't do it either.

i believe i have to divide the vector length float with the maximum distance of "1" being located away from the actor? hmm, can you understand what i mean? haha.. i tried that, but it didn't work.

avatar image Erasio Oct 16 '14 at 09:28 AM

Well I did not get all of it but I think I know your problem.

The thing is the lengh of this path is always several hundred. One unit represents 1 cm if I recall correctly so yea...

The easiest solution I can come up with would be dividing the result from "Vector Length" by the distance you want and subtracting 1 so it will be 0 if it's exactly the distance, negative if it's lower (which will be normalized to 0) and then become slowly more until it is capped at the doubled distance which you divided by. At that distance it will be 1.

I'm currently not at home and can look for a proper solution. Give me until this evening for that :)

avatar image [PB]Aphexx Oct 15 '14 at 11:55 PM

concerning the link.

i was out after the second answer...unfortunately :(

avatar image [PB]Aphexx Oct 16 '14 at 04:27 PM

thx erasio,

your last addition solved the problem. this worked. although i altered the "size by life" particle module instead of the opacity since this fits better. thank you very much!

greetings! alt text

avatar image Erasio Oct 16 '14 at 08:07 PM

Awesome. I would've looked into another way now but well. More time for series this evening for me ;D

Please check the "Accept this Answer" button at the very first answer I gave so others know as well that this is solved. Otherwise someone will most likely come back to this post and he/she will probably not read through everything we wrote here so they will just answer as well. ;)

avatar image [PB]Aphexx Oct 16 '14 at 09:28 PM

sir, the deed is done. :) thx again!

avatar image [Epic]homeRye STAFF Oct 20 '14 at 07:12 PM
avatar image [PB]Aphexx Oct 21 '14 at 06:51 AM

thank you homerye! this is a very useful tutorial series! i didn't know about the sphere mask either. however in my latest example i modified the particle size in the end. is this also possible to do in a material? perhaps by modifying the world pos offset or so?

avatar image [Epic]homeRye STAFF Oct 30 '14 at 03:34 AM

Yes, you should be able to do this with WPO.

I am not in front of the editor at this moment, I believe there is a material function that will do this for you. Try searching for distance scaling or scaling in the material editor.

(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