Set Timer by Function not working and no error nor warnings? Glitch?

Hi, I’m working on a game where the main character can transform upon picking up powerups. The powerup only lasts for few seconds and the character transforms back to its original form.

Here’s the problem: The timer doesn’t always work. There are times when I’d get a powerup and never go back to the original form. What’s worse is that the editor doesn’t count it as an error so there are no errors/warnings that popup after I test the game.

The characters look like these for now. The one on the far left is the main character, the other two are the transformations.

Here’s my blueprint set up:

Power Blueprint- When the Character touches power, the main character transforms

Hero (Character) Blueprint - contains the MorphToHero Function

This was quite hard to figure out what went wrong as I don’t get any errors/warnings. I linked the .zip of the rest of the project if you want to take a look.

[click this to open the link][6]

Thanks in advance!

Hi juztinmikael,

That zip only contains the assets and not the .uproject file. A lot of references are missing and the blueprints don’t compile. Could you post a version that I can open directly and test? You can PM me a link to download it directly over the Forums if you prefer. Please include repro steps from project start.

I did attempt to reproduce your issue but I couldn’t get the same results. How many times does the timer work vs not work? 1 out of 10? 1 out of 100?

Hi TJ Ballard,

I’ve attached the .zip with .uproject file here. I hope this works
[updated zip][2]

KeyBindings

126700-keybindings.jpg

WorldSettings

there’s also a test map in there if it helps

My problem, for now, is that the transforming mechanic doesn’t work properly. I’ve tried to reproduce the problem in PIE and its work-vs-not-work is around 1 out of 5 (20%). I also noticed that the problem gets worse when the Boss_BP is not set to destroyed actor, it goes up to 90%. I’m not sure why this happens.

How should I go about this?

Thank you,

Hi juztinmikael,

Sorry for the delay.

So it looks like it’s a logic issue in your Boss_BP. Currently; OnComponentHit you have it cast to the Blocker_BP > On Fail > Cast to Enemy_BP > On Fail > Cast to Character. This seems to be causing the issue. You need to either add in some sort of logic that it only cast to the correct actor when it is hit or change the Cast To Character to Cast To Hero_BP. That seems to work as well.

Let me know if that fixes the issue on your end or not.

Hi TJ,

It didn’t fix the issue on my side. I don’t quite fully understand how does the Boss_BP affect the SetTimer from my Hero_BP? When the boss is present in game, the character transformation doesn’t work at all. How should I go about this? Thanks

I FIXED IT ! ! Here’s how I figured it out.

This game is basically like Temple Run: You run away from the monster chasing you. So what’s happening in my blueprint is that everytime the player transforms, the old character gets hidden then a new one spawns, after few seconds the player reverts back to its original form.

Well the problem was the Boss_BP (enemy in this game) destroys even the hidden actor causing the set timer to not call its blueprint. So what I did was that after I hid the main character, I moved it to the side so the enemy wouldn’t kill it.

Here’s the problem

1.Player Transforms, OldCharacter gets left behind at the spot where the powerup was

2.Enemy Catches it and kill it

Here’s the Fix

MainCharacter now hides to the side to avoid the enemy’s kill sphere

The blueprint is pretty much the same as I inserted in the previous answer, I just added AddWorldOffset before the set timer.

The simplest logic is basically:

Power Overlap > Cast to MainCharacter > Set Actor Hidden > UnPossess > Spawn NewActor > Possess > AddWorldOffset > Set Timer by Event > Add Score > Destroy PowerUp Actor

THANK YOU :smiley:

Hi TJ,

I wasn’t able to figure it out your way, but I figured out what’s causing the problem. I came up with a solution that was easier for me to execute and understand.

The problem was the enemy killed the main character even though it was hidden. From there I tried to make a simple fix to it.

Thank you for taking your time on helping me, I appreciate it!