Store position of player at time of button press

Heyo, I am new to C# scripting in Unity and can’t for the life of me figure out this (what I assume to be an easy) problem:

When I hit jump, I want to store the last ‘known’ position of my character controller in a vector3.

I thought I could have an
if(!isjumping){
storedPosition = player.position}
at the beginning of my jump function but that doesn’t seem to work. When I press jump and isJumping changes to true, wouldn’t ‘storedPosition’ remain the last value?

In coding in general: What’s the term for stuff like this so I know what to Google for?

Thank you!

Hello,

In these kind of situations it’s usually a good idea to put some Debug.Log lines in the code to write whats going on to the console log. For example one in the line after where the storedPosition is supposed to be changed.
Debug.Log("storedPosition: " + storedPosition);

This will let you know if the code is running, at all, or maybe more often, as you think.

1 Like

Totally not the answer I was looking for but absolutely the thing I needed to do. Thank you kind stranger!