Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by NihilScire · May 16, 2017 at 04:43 PM · 2d gamerpgwalkingcutscene

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kristinosis · May 17, 2017 at 05:28 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Setting start point for player 2d 2 Answers

8-directional orientation, top down 2D, seperate from movement 0 Answers

Add item to GUI inventory and drop him back in the scene with keys 1 Answer

2d top-down rpg direction check 1 Answer

How to make a cutscene like RPG Games 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges