Play animation in reverse from last frame played

So the title is a little off so let me explain:
I want it to where the screen fades to black if you begin dying, but if you stop from dying, I want the case to play backwards where it left off to a clear screen again. How can I do this guys?

you could do this:


and your “Fade” Action goes from 20 (white) to 0 (black)

(the second property sensor is necessary if hp suddenly jumps over 20)

Ill test that out today. Thanks

Or use Flipper type. However that needs to have the sensor on no pulse.
You need to have a fading animation.
However using properties is probably a better idea.


1 Like

Still testing out the given ideas. Having some scripting issues

it takes time…I started using BGE about two months ago??? I lost track…maybe one month…anyway the key thing to do is to stay on target…if you come to a roadblock do something that will still advance your project, even if it is something simple…getting a ‘win’ will keep you motivated enough to keep trying, give you a break from what you were stuck on, keep you progressing and give you , hopefully, a fresh angle to attack your problem.

let the action actuator play in property mode.

animate your fade screen (fade in/out) over lets say 60 frames.(or as much as the hp you got)
now the animation will play according to the property, so you can either with bricks or with python increase/decrease the property and it will fade in/out.

So @Leralasss was right. I had to slightly modify how he did it. The issue I was having for the most part was:
A) the object that faded was in an overlay scene so figured out how to edit objects in another scene.
B) fade animation needed to be on another object due to collisions in animations.

I’ll post a full solution tomorrow with all the details. Thanks all!

First things first, I have my main game camera set to have an overlay scene like most games will have. Simple enough.

However, I have two different fade animations. Because of this I had to make 2 separate objects; one for the first animation and the second for the death fade.

I created the property that I wanted to make manipulate the frames then created an always sensor to the action. As you see below, I only have that property on the object and an always timer to the action where I set the action dependent on the property I set. We’ll manipulate this property in our script:


Since this is on my overlay scene, I had to create a python script to connect to the objects from my main scene to the overlay. This was a bit tricky but after some time and research here’s what I came up with:


import bge

cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getSceneList()

game = scene["Gameplay"]
overlay = scene["Overlay"]

suffocating = game.objects["Brains"]["Suffocation"]
dehydrating = game.objects["Player Stats"]["Dehydrate"]
starving = game.objects["Player Stats"]["Starve"]
freezing = game.objects["Temp Gadge"]["Freezing"]
durability = game.objects["Brains"]["Durability"]
gp = game.objects["Brains"]["Game"]
intro = game.objects["Player"]["Start"]

if intro == False:
    if suffocating == True or dehydrating == True or starving == True or freezing == True:
        overlay.objects["Blackout"]["Dying Timer"] += 0.5

    elif suffocating == False and dehydrating == False and starving == False and freezing == False:
        overlay.objects["Blackout"]["Dying Timer"] -= 0.5
        
    if overlay.objects["Blackout"]["Dying Timer"] < 0 or gp == False:
        overlay.objects["Blackout"]["Dying Timer"] = 0
    
    if durability == 0:
        overlay.objects["Blackout"]["Dying Timer"] = 250
        
elif intro == True:
    overlay.objects["Blackout"]["Dying Timer"] = 0.0

if durability > 0:
    game.objects["Brains"]["Dura Timer"] = 0

I have all my properties that can be used for death set at the top and specified that they are in my “Gameplay” scene. I then specified the properties of the specific object in my “Overlay” scene as well. It’s all simple fudge math and testing to find the right way for it to be animated.

If you have any other questions, please let me know. I am more than happy to help! :smiley:

You never need to write

if condition == True: 

it is already boolean. There is no need to check it twice.

With a proper naming you will see it is much better to read.