Printing a text if character falls

Hello everyone, im sorry in advance if im asking or saying too many stupid things, im extremelly new to Unreal Engine (started a week ago).

Im taking a course in which one of the exercises asks you to make it so if the character falls for longer than 2 seconds, a text saying “you are dead” is displayed and then the same level/map restarts (its a sidescroller with platforms, super basic)

The exercise asks you to make use of the function “is falling”, branches, and a float counter that stores how long the character is considered “in free fall” and if the character is falling for more than 2 seconds is considered dead, if not, the variable “Char fall” should be set to value 0, and when it is considered dead, then you print the text and restart the level.

Since im already making use of the Event tick for controlling the face rotation, i’ve created a second event tick, but i cant make anything work (to clarify, i just copied/pasted the original event tick and renamed it, maybe it doesnt work like that)

This is the graph i was trying to make it working:

Million thanks in advance, i’ve been trying to search for answers in other psots and videos for hours but i cant make it worj so you are my last hope for the rest of the weekend haha.

What you have done is create a new event and named it “Tick2“. In order for it to be executed, something has to call/invoke it. The engine will automatically call “Event Tick“ but it doesn’t know that you want your new event called.

The short answer is that you can call it in your “EventTick“:

A better solution would be to encapsulate your falling code in a function, not an event. Then you can call your function similarly to the above.

Create a new function using the + button on the left side under Functions:

Set your functionality in the function node graph:

You can add inputs and outputs for your function using the settings menu on the right:

And finally call your function in your “Event Tick“:

1 Like

Hello @Slayn how are you?

Welcome to the Unreal world! Hope you are having a great time with the engine!

You are doing it great! But I can see some issues with your blueprint that I’m going to try to fix.

First of all, you cannot have tw different “Event Tick” events, you will need to work with only one. Remember that all your connected nodes will be activated in sequence, so you can connect your “Dead by Falling” code immediately after any other thing you already have in your “Event Tick”.

Now lets check your blueprint:

  1. The first problem is that the custom event “Tick2” is not being called anywhere (it is NOT an Event Tick, just a custom event, as you cannot duplicate the Event Tick).

  2. You should be using the Delta Seconds to increase your “Char Fall” variable instead of a “++” node.

  3. I highly recomend you to add a “Fall Limit” (float) variable to use it as the target seconds in which the player will die if it’s falling.

Your blueprint should look something like this:

Remember you can connect this part of the blueprint after anything you already have in your Event Tick, just be sure to connect the Delta Time to the corresponding pin.

Now that the check for falling is working, I have a couple extra recomendations!

Instead of adding that chunk of code directly to the end of your Event Tick blueprint, you can create a custom event with the code inside, and then, call it at the end of your Event Tick by right clicking on an empty space and searching your custom event as you do with any other node. It should look like this:

  1. Custom Event with Falling code:

  2. Custom event called immediately after a different event/function on the Event Tick

As you can see, the custom event “Dead by Falling” has an input, which is a float variable to get the Delta Time from the Event Tick. To add that input, after you create the custom event, you can go to Details panel and click on the “+” icon in the “Inputs” section, as shown in the image below:

One last warning: be carefull with the “Delay” node as it delays anything after it!

Hope this helps you!! Let me know if you need more help with this!

1 Like

Thank you so much Juan!

Im trying to implement your solution, however it doesnt seem to work, let me go part by part:

1- Let me show you where im using the original Event tick (it was part of a previous exercise that keeps iterating on a level adding features, like the fall text and map reload)

In this case, Event tick is being used to check the direction the character is looking and set it to the right direction (not ethat i added at the end a “trigger death” custom call at the end as you suggested)

2- Now as i said, i was testing the custom call (i didnt know you could do this, thanks a lot!) first i tried by just using the actual custom event that i created based on your suggestion but not modifying anythng else (i just like to understand how things work wven when they are wrong, it helps me to learn better):

  • Funny thing, the text is actually displayed the second the character is in the air non stop, still the level reloads.

Then, what i did is to actually implement your solution with all the changes you mentioned (using delta seconds instead of “++” and so) as you can see here:

However, for some unknown reason it doesnt work.

I guess you will ask so yes, the “Fall Limit” var value is set to “ 2 “ as you can see here:

I hope is not one of those cases where im just so tired that i missed something super evident that makes me look even more stupid hahaha

Anyways, thank you and everyone else for your help! i didnt expect this forum to be so helpful, really thank you so much guys!

(post deleted by author)

Scroll up to my previous post. It’s the easiest most direct approach using the functionality already built in to the character class.

Thank for your your help sir! unfortunately i have to use the structure i have as the exercise is expecting me to do so and not just use anything else that works, even if its more efficient or easier, so even if your solution works (i didnt test it) i cannot use it as the solution for my exercise, so thanks a lot anyways! but i cant use it sadly.

My Bad! I was going off what others where saying. 100% didn’t see the criteria.

Anyway, here’s how I’d do it if forced to use Tick delta seconds.

Return nodes immediately exit the function.
Sequence [Then 0] Branch condition only exits on a False result.
A True result will cycle to sequence [Then 1] and finish execution.

Just a cleaner process to read setting it up this way.

2 Likes

Million thanks! this worked perfectly! :slight_smile: