- Home /
Inertia/Smoothing Advice
I'm relatively new to Unity and the languages as well, and have been having some issue trying to figure out how to get some form of smoothing applied to the following:
transform.Translate( Vector3.right * -Input.GetAxis( "Mouse X" ) * panSpeed );
transform.Translate( Vector3.forward * -Input.GetAxis( "Mouse Y" ) * panSpeed );
I've dug around online and here and in the scripting manuals, but everything I've found has either confused me more or applies to a completely different style of movement. I assume I need to cache the current transform, then apply the Translate and use a Lerp or some other form of smoothing between the two values, I'm just sort of at a loss as to how to even begin to start.
Any tips, advice, or pseudo-code or a point in the proper direction would be greatly appreciated. I apologize if this is the wrong way of doing this, but I'm just frustrated and would rather not waste more time searching for a solution. Thanks in advance.
Answer by Bunny83 · Oct 07, 2014 at 11:50 PM
MouseX and MouseY are delta values, so they reflect the direct movement during the lastframe and the current. It's difficult to smooth such values directly. It's easier to use an empty target object with your script above and let the actual gameobject follow that target object. For that you could use the SmoothFollow script from the standard assets or do your own smooth follow.
I see. I think that's ultimately what I was trying to ask, because either way there's some form of Lerp or smoothing that takes place between one transform and another basically, right?
I didn't necessary wish to smooth the $$anonymous$$ouseX or $$anonymous$$ouseY values, but the final product that those drive. I just don't know where exactly to begin. I wasn't aware that there was a Standard Asset for SmoothFollow, so I'll check that out and see if I can figure it out, but I'd still appreciate any advice if anyone else has further input. Thanks.