It’s working fine, the camera zooms in when I crouch, and zooms out when I sprint, then returns to original position when I walk. Problem is when I crouch > sprint, then the Lerp screws up and zooms only halfway, leaving me with a zoomed in walk when I stop sprinting. What can I do to make this work?
a few things: I would really suggest an enum over the bools; as the logical context will seem less arbitrary, and you can also include switch
block nodes and a single direct assignment, given the current context you will only have 3 states Walk, Run, Crouch; there are 6 situations for this event cluster: Walk->Run, Walk->Crouch, Crouch->Walk, Crouch->Run, Run->Walk, Run->Crouch
the other thing is that your A and B values into any but the first Lerp()
calls in the chain are really ambiguous and might just be random (in the best case they will be the last cached value of that execution line. typically B is the Target Value
and A is either the Current value or an arbitrary value.
there are 2 potential fixes
- make the values come out of an exec function so they are cached: this could have as few as 2 bool/1enum input, 3 float outputs, and maybe 2 bool (there is the situation where you could have “Run->Run” which doesn’t make sense in your context, so no change to the Timeline)
- or have your Run, Walk, Crouch values be stored in Variables so that you are not going through a chain of 3 Lerps.
either of these methods you should be able to go down to 1 Timeline and Lerp.