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 Emerald_Eel_Entertainment · Aug 25, 2017 at 03:43 PM · movement3dfps controllerfirst person controllersmoothing

Standard FPS Controller - Smoothing Movement

I noticed that when you move the Standard Assets FPS controller via the WSAD keys, the moment you let go of any key to stop it from moving it instantly halts any movement it was making.

I tried looking through the FirstPersonController.cs script to find anything to do with smooth the transition between movement and suddenly stopping, but I couldn't seem to find any. I saw the smoothing option for the camera movement but nothing to do with the physical movement.

Admittedly programming isn't my strong suit. I would very much appreciate if anybody has a solution to smooth the sudden halting.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by SolomonG · Aug 25, 2017 at 11:07 PM

A simple solution would be to employ trapezoidal acceleration. It sounds scary but it's not. Essentially you simply speed up or deaccelerate according to a maximum acceleration (change in velocity/speed), as opposed to always setting you actual speed to how fast you want to go.

In pseudocode form:

 update() {
     // If the difference is more than how much we can accel in a frame
     if (actualSpeed < targetSpeed - maxAcceleration) actualSpeed += maxAcceleration;

     // If the difference is more than how much we can deaccel in a frame
     else if (actualSpeed > targetSpeed + maxDeacceleration) actualSpeed -= maxDeacceleration; 

     // else we're either on target or close enough (+/- maxAccel/maxDeaccel)
     else actualSpeed = targetSpeed 
 }

Comment
Add comment · Show 3 · 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 Emerald_Eel_Entertainment · Aug 26, 2017 at 09:35 AM 0
Share

I will try copy-pasting your solution into the Update section of the code. I have a lot to learn so I'll have to take your word for it, haha. :)

avatar image Emerald_Eel_Entertainment · Aug 26, 2017 at 09:48 AM 0
Share

Okay so I copied the code you wrote beneath the private void start section but above the private void update section. It looks like this so far:

 void update()
       {
       // If the difference is more than how much we can accel in a frame
       if (actualSpeed < targetSpeed - maxAcceleration) actualSpeed += maxAcceleration;
 
       // If the difference is more than how much we can deaccel in a frame
       else if (actualSpeed > targetSpeed + maxDeacceleration) actualSpeed -= maxDeacceleration;
 
       // else we're either on target or close enough (+/- maxAccel/maxDeaccel)
       else actualSpeed = targetSpeed
       }

I saved the script but I received an error:

Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs(70,7): error CS1002: ; expected

I have no clue what this means or how to fix it. I've missed something haven't I?

avatar image ChristianBlandford Emerald_Eel_Entertainment · Apr 28, 2020 at 09:33 AM 0
Share

I know this is very late, but you've missed a semicolon at the end of the last "else" statement :)

avatar image
0

Answer by lastnoob765 · May 08, 2021 at 09:20 AM

Change the input from GetAxisRaw to GetAxis and use lerp to smooth it out.So when i let go of the keys it will have some momentum left and stop 0.1-1s later.Depending on lerp amount

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

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

Related Questions

Jerky motion when standing on hovering object, 0 Answers

Networked position interpolation implementation (not Dead Reckoning)? 1 Answer

How can i make my RigidBodyFPSController to move when Is Kinematic is true ? 1 Answer

3d Space Movement 1 Answer

Locking movement to one axis only (3D game) 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