How would you make a 2D NPC walk from one point to another for a cutscene?

Sorry for the really basic question, I just started learning Unity and was trying to make a basic 2D pixel RPG. I haven’t been able to find a good answer for this even though it’s pretty simple.

Basically, at the start of the game I want there to be a “cutscene” of the characters walking into the screen to a specific point, then stopping. They would then have a dialogue box conversation before the user can move around. It’s not going to be a video cutscene, and instead use the character sprites and walking animations I already built into the game.

I think that the probable way to solve this would be to use a script attached to the characters, but I cannot for the life of me figure out how to make the characters walk naturally to the spot.

As a test I used:

myRigidBody.MovePosition(transform.position + new Vector3(0,1,0));

Which only moves the character instantly to a spot on my map.

I also tried something like

myRigidBody.velocity = new Vector2 (0, moveSpeed);

Which does work because my character will move upwards with a walking animation, but she will never stop walking until she hits a collider.

My main questions are these:

  1. Is there a way to make the characters walk up, turn and walk right, then stop while still using the walking animations I attached to the sprites? I used a Blend Tree for animations.

  2. I am also unsure whether the code should be in start() or update() since it only runs once in the beginning of the game.

Thanks for any help.

I would probably just update the character’s transform position instead of using the rigidbody. The rigidbody is good for actual gameplay physics but since you’re doing this in a cutscene you don’t have to worry about collisions or anything. That being said, you can lerp between the character’s current position and a position you want to get to:

Vector2 targetPos; //The position you want your character to end up at
float moveSpeed; //How quickly you want your character to move there
transform.position = Mathf.Lerp(transform.position, targetPos, moveSpeed);

If you want your character to move through different points one after the other, you could hold the target positions in an array or list and compare the character’s position to each point before moving to the next.