I want to store my current actor’s location in a TArray. Suppose I’m moving from one position to another position I want to add those positions in a TArray and after a few seconds I need to recall those positions to play it again. I want to add the positions in the tick function is it possible to add them in the tick function?? or will it create any performance issue by adding the position in the TArray during event Tick please help me with this issue.
Can you explain what exactly you’re trying to accomplish? Getting the actor’s current location on tick and saving it in an array should be possible but I don’t understand what you mean by playing it again.
Yes, you can do that but given the number of elements you will be adding I’d suggest one or more of the following:
Be sure to initialise your array to a suitable (large) number of elements to avoid needing to allocate / reallocate lots of memory as the array increases in size
Use some sort of smoothing. When I’ve made systems like this before I’ve tried where possible to make it more of a keyframe system with interpolation between those points. Keyframes would normally be made at important points. The exact implementation / suitability depend on your game of course
Hey I’m planning to do killcam for my game. In that we need to store the current position in a TArray then after death we need to call the last 5 -10 stored TArray values to show a replay how he was dead.
How exactly is your kill cam supposed to function? If it’s meant to show who killed the player, you should be able to attach a cmaera/spring arm to the character. If you want to see how the player died in the kill cam it would involve a replay of the seconds leading up to the player’s death.
The method ii) I want to see how the player die in the killcam like a replay of few seconds is it possible by fetching all the positions in a TArray and I need to fetch the proper animations too.
Hello Game Programmer. There is currently a bug in for the Demorec and Demoplay functions as they are causing some crashing problems. Using those functions would be ideal to setting up killcam replays as it can record all of the gameplay for playback.
If you’re concerned about performance issues with storing those values on tick, I’d suggest using a looping timer with a 0.1 second duration. In some situations, this might even be less performant than using Tick as Timers aren’t built to be called that rapidly.
As far as the TArray goes, to avoid it becoming too large, I’d suggest setting up the loop to use Push to add the array elements and dropping the last element if the array’s size reaches 10. If you only need 10 positions, getting rid of those last elements should be alright.