Obtain position value 6 frames before event

I have been stuck at how to make a script that would allow me to get the velocity of the player about six frames before hitting a trigger. I figured I would need an array to get the CharacterController.velocity every frame and then discard the last value in the array every frame. Finally I would need to pull the last value out of the array once the controller hit the trigger. I have never used an array before so it would be great to have a starter script to go off of. Thanks in advance.

I’d recommend you to not rely on actual frames. Perhaps a second trigger would do the trick, where you first check the velocity on the first trigger and then execute on the second trigger. Even though it’s not related to the answer - have a look at arrays over here:

In the Reference

At the Wiki