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
0
Question by RkySmart · May 28, 2013 at 12:32 PM · rotateforwardwalkingleftright

Walking forward

I know alot of questions about this already, but not like a I want. I want my character to move only forward and rotate left and right.

I have the script to rotate

 function Update () 
 {
      if(Input.GetKey(KeyCode.LeftArrow))
           {
                transform.Rotate(0f,-5f,0f);
           }
 
 
       if(Input.GetKey(KeyCode.RightArrow))
           {
                transform.Rotate(0f,5f,0f);
           }
 }

Very simple script. I don't know if possible to do something like that to walk forward.

 if(Input.GetKey(KeyCode.UpArrow))
      {
 
      }

Thanks for the help :)

Comment
Add comment · Show 1
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
avatar image Lovrenc · May 28, 2013 at 12:36 PM 0
Share

I dont know what you want.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by SubatomicHero · May 28, 2013 at 12:48 PM

You need to look into using Time.deltaTime as part of your movement scripts. It helps keep movement smooth.

Moving forward would just be a case of using transform.Translate(....);

Hope this helps.

Comment
Add comment · Show 4 · 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
avatar image RkySmart · May 28, 2013 at 04:33 PM 0
Share

thanks works like I want, but one question.

I don't know if it is because of that but the player goes through walls.

Any solution please?

avatar image delogan · May 28, 2013 at 04:37 PM 0
Share

You need to add colliders/rigidbody physics components to your objects in order for them to react to each other. You can read further on this topic here: http://docs.unity3d.com/Documentation/$$anonymous$$anual/Physics.html

avatar image RkySmart · May 28, 2013 at 05:03 PM 0
Share

I tried a box collider, capsule collider and character controller.

But it stills going through walls (walls also have a box collider)

avatar image delogan · May 28, 2013 at 05:41 PM 0
Share

http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html

avatar image
0

Answer by ragnaros100 · May 28, 2013 at 12:49 PM

Transform.Translate() should work properly here

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make a cube rotate in right or left direction randomly 3 Answers

Rotating a cube changes its local forward? 1 Answer

left and right movement for ai 1 Answer

Check where mouse is clicked 1 Answer

Move player to left and right ( android Touche ) 0 Answers


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