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 AGwynne · Aug 06, 2017 at 11:29 PM · player movement

Player Gravity is too slow

I'm making a networked FPS and want to have realistic physics, but when i drop the player that is being controlled, the gravity is extremely slow (it falls at around 0.1 units per second). But, when I drag an instance of the player prefab into the scene (one not controlled by anyone) it falls at a normal speed.

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 AGwynne · Aug 06, 2017 at 11:39 PM 0
Share

Using Debug.Log(Rigidbody.velocity.y) returns 0

2 Replies

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

Answer by NorthStar79 · Aug 07, 2017 at 11:14 AM

every time you move (maybe every update call idk) you set your char velocity = 0 here : Rb.velocity = Vector3.zero; that prevents gravity. its not necessary as far as i see in your code. soo, i suggest just delete that line. and you are good to go.

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 NorthStar79 · Aug 07, 2017 at 11:17 AM 0
Share

and another tip. dont use "==" for checking float. at line 10 : you should use $$anonymous$$athf.Approximately(Rb.velocity.x,0f); ins$$anonymous$$d of (Rb.velocity.x == 0

avatar image AGwynne · Aug 07, 2017 at 02:04 PM 0
Share

Even removing that line the player still doesn't fall. It will fall correctly if i comment out the call for the movement function, but when i put it back in, it stops working.

avatar image NorthStar79 AGwynne · Aug 07, 2017 at 02:49 PM 1
Share

try to add this line between line 8 & 9 velocity += rb.velocity.y;

avatar image AGwynne NorthStar79 · Aug 07, 2017 at 03:31 PM 0
Share

That got It working, Thanks

avatar image
0

Answer by AGwynne · Aug 07, 2017 at 10:43 AM

I have narrowed down the problem to my movement function:

 private void Move()
     {
         Rb.velocity = Vector3.zero;
         float hMove = Input.GetAxisRaw("Horizontal");
         float vMove = Input.GetAxisRaw("Vertical");
         Vector3 moveHorizontal = transform.right * hMove;
         Vector3 moveVerical = transform.forward * vMove;
         Vector3 Velocity= (moveHorizontal + moveVerical).normalized * speed;
         Rb.velocity = Velocity;
         if (Rb.velocity.x == 0 && Rb.velocity.z == 0)
         {
             Animator.SetBool("IsWalking", false);
         }
         else
         {
             Animator.SetBool("IsWalking", true); 
         }
 }


I assume that the Y velocity is being overwritten but i don't know how to fix that

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

68 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

Related Questions

Network Transform Component forcing Object to a specific position + rotation 0 Answers

Player movement question (Unity3D) 2 Answers

Double jump problem C# 2 Answers

How to move a child object freely (within), when parented to a new parent Object? 2 Answers

Player Stopping Suddenly? 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