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 PyroChiliarch · Feb 05, 2014 at 07:47 AM · javascriptcharactercontrollernewbie

Character Control General Issues

I do not want to use the character controller that comes with unity because i want to learn how to do this myself. I have about three issues (This is first person game btw):

1) My character accelerates exponentially, just going faster and faster until i stop pressing the forward button. How can i setup a max speed?

2) Fixed When i look down and move forward i don't move forward, this gets worse the further i look down.

3) How do i go about making my character accelerate faster?

I have googled this but the usally say things like "use the unity character controller" or are in C#.

 //Players Abilities
 var playerSkill_strafeSpeed = 10;
 var playerSkill_walkSpeed = 15;
 
 //Player Moving around
 function FixedUpdate () 
 {
     if (Input.GetButton('player_forward'))
     {
         rigidbody.AddForce(transform.forward * playerSkill_walkSpeed);
     }
     
     if (Input.GetButton('player_back'))
     {
         rigidbody.AddForce((transform.forward * playerSkill_walkSpeed) * -1);
     }
     
     if (Input.GetButton('player_right'))
     {
         rigidbody.AddForce(transform.right * playerSkill_strafeSpeed);
     }
     
     if (Input.GetButton('player_left'))
     {
         rigidbody.AddForce((transform.right * playerSkill_strafeSpeed) * -1);
     }
 }
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
Best Answer

Answer by NickP_2 · Feb 05, 2014 at 10:17 AM

If you modify the 'drag' property in the rigidbody's inspector, the air resistance will be modified. The larger the number, the more air resistance.

What does this do? I'm not a physicist, but I noticed the larger the drag, the longer it takes for an object to reach his max speed. Sow hen you modify the drag, the object will start slow, and accelerate until a certain speed is reached.

This isn't easy to control tho

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 PyroChiliarch · Feb 05, 2014 at 08:18 PM 0
Share

Thank you for answering, the objects drag was currently on 0 and i want to increase the acceleration. Yes you are right but doing that for this object wont work. (Unfortunately setting it to negative numbers doesn't work.)

avatar image PyroChiliarch · Feb 12, 2014 at 10:08 AM 0
Share

the answer is no longer needed because i have figured it out and my code is now very different

avatar image NickP_2 · Feb 12, 2014 at 11:11 AM 0
Share

Oh awesome :) van you share with us what you did?

avatar image PyroChiliarch · Feb 20, 2014 at 09:37 PM 0
Share

The code is very different because it now takes input from joysticks

 var Rotation_Speed: float = 60;
 var Speed_Forward: float = 30;
 var $$anonymous$$ax_Speed_Forward: float = 5;
 var $$anonymous$$ax_Speed_Backward: float = -5;
 var Centre_Of_$$anonymous$$ass: float = 0;
 
 function Start ()
 {
     //Set the centre of mass
     rigidbody.centerOf$$anonymous$$ass = Vector3 (0, Centre_Of_$$anonymous$$ass, 0);
 }
 
 function FixedUpdate () 
 {
     var rotation = Input.GetAxis("Horizontal_Legs") * Rotation_Speed * Time.deltaTime;
     transform.Rotate(0, rotation, 0);
     
     if (((Quaternion.FromToRotation(transform.forward, Vector3.forward) * rigidbody.velocity).z < $$anonymous$$ax_Speed_Forward) && ((Quaternion.FromToRotation(transform.forward, Vector3.forward) * rigidbody.velocity).z > $$anonymous$$ax_Speed_Backward))
     {
         var forward = (Input.GetAxis("Forward_Legs") * Speed_Forward) * -1;
         rigidbody.AddForce(transform.forward * forward);
     }
 }

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

19 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 avatar image avatar image

Related Questions

AI movement using Character Controller, turning problem 1 Answer

character turning problem! 0 Answers

CharacterController unexpectedly moving up 0 Answers

How to move player with xbox controller 1 Answer

Pick-Up Object With Mouse Hold 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