Home Unreal Engine
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

Store value from last frame and comparing it to current

So I've been home sick for almost a week now and made this super overkill cigarette shader.

https://www.youtube.com/watch?v=uZOCA49TiFg

Everything is dynamic except for deciding whether the cigarette should "keep" it's ashes or not. I want to fix this by checking the cigarette's movement by storing it's position from last frame and comparing it to current. Any idea how to do this?

Replies

  • Rooster128
    Offline / Send Message
    Rooster128 polycounter lvl 8
    It'd probably have something to do with the tick event, and using a delta (not sure if blueprints uses delta or not- basically you want to check the time each tick takes in milliseconds, usually that's called tick length).

    If you're problem is just storing the position value and saving it, I think what you could do is create a new variable in the blueprint called old_position or whatnot, change it to type vector, and at the end of every tick (after your logic for the ashes is done), set the old_position variable to it's current position.

    Hope this makes sense! Sick shader btw- that looks very realistic!
  • JoakimMellergard
    Rooster128 wrote: »
    It'd probably have something to do with the tick event, and using a delta (not sure if blueprints uses delta or not- basically you want to check the time each tick takes in milliseconds, usually that's called tick length).

    If you're problem is just storing the position value and saving it, I think what you could do is create a new variable in the blueprint called old_position or whatnot, change it to type vector, and at the end of every tick (after your logic for the ashes is done), set the old_position variable to it's current position.

    Hope this makes sense! Sick shader btw- that looks very realistic!

    Thanks! I'll certainly try this out. :)

    I realised that I have another problem to take care of aswell.. I'll try to demonstrate:
    As it is now:
    The cigarette starts to burn - no movement. There will be ashes. The cigarette moves and the ashes disappear. The cigarette stops to move and ALL of the ashes will come back.
    But I have a feeling it shouldn't be to hard to figure this out.
  • JoakimMellergard
    Hmm I am having some trouble setting up your idea. Basically, what I want to do is this (written in pseudo code):

    This also helps fixing the problem i mentioned in the other post.

    1. oldPosition = vector3(0,0,0)
    2. newPosition = vector3(0,0,0)
    3. ashes = 1.0
    4. burnAmount = the curve that defines how much of the cigarette that has burned
    5. function Position:UpdateEveryFrame()
    6. newPosition = getPosition(cigarette)
    7. if(oldPosition == newPosition)
    8. oldPosition = newPosition
    9. ashes = ashes
    10. else
    11. oldPosition = newPosition
    12. ashes = burnAmount
    13.  
    14. end
    and then I can use the ashes value to set the opacity :)

    So do you know how I can make that script in nodes?
Sign In or Register to comment.