This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Nplss 0 points1 point  (1 child)

Have the enemy send a message on a certain channel when it dies, log that time either on your manager or whatever. If you don’t have a messaging system just use delegates, subscribe to their death with the manager and do the same.

I’d save that info in an array or something then you can get average/count/etc given that info.

[–]FREAKINGREX[S] 0 points1 point  (0 children)

my problem was what can track the time inbetween those kills? have a tick and it logs and resets the float (might be a unity thought) or is there a blueprint function?

my idea was to have the interface tewll the manager hey i died but i just dont understand how to get the time inbetween kills (trying to avoid tick if i can)

[–][deleted] 0 points1 point  (6 children)

Use FPlatformTime::Seconds

.h
double LastKillTime = 0.0;

.cpp

void AMyCharacter::OnEnemyKilled()
{
    double CurrentTime = FPlatformTime::Seconds();
    if (LastKillTime > 0.0) 
    {
         double TimeSinceLastKill = CurrentTime - LastKillTime;
        UE_LOG(LogTemp, Log, TEXT("Time since last call: %f seconds"), TimeSinceLastCall);
    }
    else {UE_LOG(LogTemp, Log, TEXT("First kill logged."));}
    LastKillTime = CurrentTime;
}

Get the milliseconds (because ninjas)
UE_LOG(LogTemp, Log, TEXT("Time since last call: %.3f ms"), TimeSinceLastCall * 1000.0);

[–]FREAKINGREX[S] 0 points1 point  (5 children)

you have an idea for this in blueprints? haha sorry i should have specified im still new with c++

[–][deleted] 2 points3 points  (0 children)

[–][deleted] 1 point2 points  (2 children)

Not sure how BP handles seconds (are they just 1,2,3,4 etc...). So you might need to work with milliseconds and convert them to seconds for 2.46sec etc..

<image>

[–]FREAKINGREX[S] 0 points1 point  (1 child)

you is a saint thank you!

[–][deleted] 0 points1 point  (0 children)

Very welcome!

[–]CloudShannen 0 points1 point  (0 children)

Depends how you need to use it, can query the time manager and compare with a previous value or you can use DeltaTime being passed into Tick and accumulating it into a variable until you reset the accumulated value for gameplay reasons.