- Home /
Move Character to touched Position 2D (Without RigidBody and Animated Movement)
Good day. I am trying to achieve simple thing but nothing just works....
The desired output:
• Player touches a place in my world
• Character starting to smoothly move with walking animation towards that location
The actual result: • Player touches a place in my world
• Character just jumps into the final point, no smooth movement nothing
Things tried:
• Vector2 finalPosition = Camera.main.ScreenToWorldPoint(position); transform.position = finalPosition;
In this scenario the character just jumps into the final point
• Vector2 finalPosition = Camera.main.ScreenToWorldPoint(position); transform.Translate(finalPosition);
In this case character just dissappears from the screen.
Any solution?
Answer by pcdrive · Jan 10, 2018 at 01:34 AM
hello there @biggdawgg!
did you tried it with simple interpolating?
i mean in update: character.transform.position = Vector3.Lerp(character.transform.position, "target", 1f);
i just wrote it from my idea the actual code may be different. The Linear interpolation smooths the movement based on the time value you gave as third parameter (float).
Your answer
