Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Steve 10 · Apr 09, 2011 at 11:40 AM · movementcharactercontroller2d-platformer

Character constant movement 2D...

I am very new to Unity and am trying to create a 2.5D sidescroller with only two interactions. For E.g, "Jump and Slide".

Therefore how do I script my character to constantly run/move so the player can concentrate on the obstacles ahead?

Thanks :)

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
2

Answer by Rabwin · Apr 24, 2011 at 01:28 PM

Wow it's been a long time since you asked and probably figured it out already, but I'll go ahead and answer since I need to clear this out of my head :D. You can simply move the player's character gameObject constantly in the update function.

Of course I'm assuming you aren't using the built-in character motor script here. If you are then have a look at the scripting reference on how to interact with character motor using scripts. And then use pretty much the same method as I will show now to move the player through that.

So enough rambling on, here's an example.

gameObject.transform.position += vector3.forward * speedMultiplier * time.Deltatime;

This line adds the vector3.forward (or z variable of a vector3) times the speedmultiplier times time.Deltatime to the character's position, moving it forward at a somewhat constant rate when each frame is rendered.

I would define speedMultiplier as a float (of course if you're doing java, it does it for you) Also I'm not certain whether it's += or -= the new position, you can play with that. But the vector3 you need should be forward, as long as your character is facing that way in the scene I guess.

Then all you need to do is play the running or whatever animation you have and match up the speed to the stepping (trial and error as far as I'm aware). You would need need input for the jump and slide, and you can make a little jump script and use the same method to move the character up and down using vector3.up (the y axis of a vector3), and sliding can use the slide animation, and increase the characters speedmultiplier variable during the animation.

I hope I was helpful.

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

No one has followed this question yet.

Related Questions

Can someone help my character move correctly? 0 Answers

How to set up two character controllers on one client? 1 Answer

How do I use the Standard Asset 2D character controller for a local multiplayer game? 2 Answers

Making character dash forward 0 Answers

Character controller wont move 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