I want to lerp my cc between current pos and a point some magnitude away from current pos over a time. I want it to lerp along the x-axis only upon pressing x.
I DON’T NEED A FULL SCRIPT!!! Actually, I don’t need any script at all!
I just need to know what needs to be done to get this one aspect for my controller. PLEASE HELP
someone has to have run into this problem before, if not then all “dashing” functions would look instantaneous. Someone has figured this out before, if you are that person then please help me. Thank you
The whole advantage of CharacterController is access to the .Move (and .SimpleMove) functions. Those functions move the CC by a specified amount, instantly, while taking into account gravity and sloping and walls and stuff.
You want to get from point A to point B, over a period of T seconds. So, how fast should the CC move per second? (A-B).magnitude / T = speed (units/second). And you probably need a direction as well: directionVector = (B-A).normalized; (The direction from one vector A to another B is always B-A, and normalizing it allows for easy application of speed/etc)
So now that you have a direction and a speed, move the CC at that speed until you arrive at your destination. I’d recommend the “am i there yet?” test to be “have I been moving for T seconds yet?” You could test for location but it’s extremely easy to foul up that sort of calculation.
Assuming all this is done somewhere else, your CC’s movement code would look like this:
function Update() {
cc.Move( direction * speed * Time.deltaTime );
}
I think you may be mis-understanding Lerp, use MoveTowards.
If you lerp is istant, you feeding to large of a number for t; its needs to be <1 try feeding your script with 0.01 so you can get a Feel for lerp, again, see move towards, or check out my explination of how to do movement over time regarding velocity in your last post: http://answers.unity3d.com/questions/348785/lerp-can-someone-explain-please.html