Hi, Well guys I am having trouble with a game that I am currently making, is in pretty early stages but I am trying to get the basics done in order to move on. My problem is the following, I am trying to make the character move to certain positions of the game when the user presses certain button, kinda of like, moving in a grid, well that was easy no problem with that, but I notice that the change of position is too fast!! I have tried different ways of moving the character but none make the character land in that exact position I desire. Code (CSharp): if (Input.GetKeyDown (KeyCode.D) && !inhabilitado && center) { hero.transform.position = new Vector2(plat03.transform.position.x , hero.position.y); } There is an example of the code I have right now... Basically, I want the player to move from point A to B in a fluid way(landing in the exact point I want) so that when I insert animations it will look good. NOTE: I have tried MovePosition and others similar ways but the player doesn't land where I want tho the movement is very fluid
It seems to give me the same result as the code I posted, the position of the player still changes abruptly. Thanks for the quick reply
Well, there is a way for doing this but I think is inefficient because it will make me try different combinations of ...AddForce and add a high level of friction to the ground so that when the player collides with it, he won't move a bit. I don't know if this is the only way posible for what I want so any other ideas will be very much appreciated.
Use Lerp. You need to use it correctly, which means calling it every frame that movement should occur. http://wiki.unity3d.com/index.php/GridMove --Eric
Oh dude thanks!!, with the script in the wiki article that you created helped me a lot to understand how to use lerp. Thanks again!!!
Sorry to bother you again, but I am trying to make some changes to the script you created in order to avoid the player to move to the right when a boolean is true, but I can't manage to do it. I was wondering if you can help me out please or someone else that knows about lerps..