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 Darixan · Aug 23, 2017 at 09:01 PM · rigidbodygravitydrag

Why does my character fall slowly even though rigid.drag = 0?

https://www.youtube.com/watch?v=F-bwle2BPiA&feature=youtu.be

The video above says all.

Here is the following code I used if you cannot see the video in HD yet:

 public class CameraManager : MonoBehaviour 
 {
     public float followSpeed;
     public Transform target;
     public Transform cam;
 
     public static CameraManager singleton;
 
     void Awake()
     {
         singleton = this;
     }
 
     public void Init(Transform t)
     {
         target = t;
         cam = Camera.main.transform;
     }
 
     public void FixedTick(float d)
     {
         FollowTarget (d);
     }

     void FollowTarget(float d)
     {
         Vector3 targetPosition = Vector3.Lerp (transform.position, target.position, d * followSpeed);
         transform.position = targetPosition;
     }
 
 }

 public class InputManager : MonoBehaviour 
 {
     public float horizontal;
 
     CameraManager cam;
     StatesManager states;
 
     [HideInInspector]
     public float delta;
 
     void Start () 
     {
         cam = CameraManager.singleton;
         states = GetComponent<StatesManager> ();
 
         states.Init();
         cam.Init(this.transform);
     }
 
     void FixedUpdate()
     {
         delta = Time.fixedDeltaTime;
         GetInput ();
         UpdateStates ();
         states.FixedTick (delta);
         cam.FixedTick (delta);
     }
 
     void Update () 
     {
         delta = Time.deltaTime;
 
     }
 
     void GetInput()
     {
         horizontal = Input.GetAxis ("Horizontal");
     }
 
     void UpdateStates()
     {
         states.horizontal = horizontal;
         states.moveDir = new Vector3 (horizontal, 0, 0);
         states.moveAmount = horizontal;
         states.moveAmount = Mathf.Abs (states.moveAmount);
     }
 }

 public class StatesManager : MonoBehaviour 
 {
     [Header ("Initialization")]
     public GameObject activeModel;
 
     [Header ("Inputs")]
     public float horizontal;
     public float moveAmount;
     public Vector3 moveDir;
 
     [Header ("Stats")]
     public float moveSpeed;
     public float dashSpeed;
     public float rotateSpeed;
 
     [Header ("States")]
     public bool onGround;
     public bool inAction;
     public bool canMove;
     public bool dashing;
     public bool jumping;
 
     [HideInInspector]
     public Animator anim;
     [HideInInspector]
     public Rigidbody rigid;
 
 
     public void Init () 
     {
         SetUpAnim ();
         SetUpRigid ();
     }
 
     public void FixedTick(float d)
     {
         HandleMovementAndRotations (d);
         HandleAnims (d);
     }
 
 
     public void Tick (float d) 
     {
         
     }
 
     void HandleAnims(float d)
     {
         anim.SetFloat ("vertical", moveAmount, 0.1f, d);
     }
 
     void HandleMovementAndRotations(float d)
     {
         rigid.drag = (moveAmount > 0 || onGround == false) ? 0 : 4;
         
         rigid.velocity = moveDir * (moveSpeed * moveAmount);
 
         if (moveDir == Vector3.zero)
             moveDir = Vector3.forward;
         Quaternion tr = Quaternion.LookRotation (moveDir);
         Quaternion targetRotation = Quaternion.Slerp (transform.rotation, tr, d * moveAmount * rotateSpeed);
         transform.rotation = targetRotation;
 
     }
 
     void SetUpAnim()
     {
         if (activeModel == null) {
             anim = GetComponentInChildren<Animator> ();
             if (anim == null) 
             {
                 Debug.Log ("No model found.");
             } 
             else 
             {
                 activeModel = anim.gameObject;
             }
         }
 
         if (anim == null) 
             anim = activeModel.GetComponent<Animator> ();
 
         anim.applyRootMotion = false;
             
     }
 
     void SetUpRigid()
     {
         rigid = GetComponent<Rigidbody> ();
         rigid.angularDrag = 999;
         rigid.drag = 4;
         rigid.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
 }
 



And yes, the gravity is at it's default -9.81 setting, but I'd like to avoid messing with that option since it might complicate things down the road.

pls help me. ive tried for a week. im desperate. thank you.

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
1

Answer by LT23Live · Aug 23, 2017 at 09:22 PM

  1. Your states manager sets your drag to 4.

  2. A lower drag means less resistance to the weight pushing it down.

  3. if you want your character not to drop any try considering one of the three things.

  • Remove Rigid Body and Use Transform.Translate

  • Increase the drag to 10000

  • Disable 'Use Gravity' on the rigid body.

Comment
Add comment · Show 1 · 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 Darixan · Aug 25, 2017 at 03:53 PM 0
Share
  1. An object with a drag of 4 doesn't fall that slowly, and the states manager sets the drag to 0 if bool onGround = false (and the video didn't show it, but onGround was false in the video).

  2. I know, I want the object to fall faster

  3. I want the character to drop faster.

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

90 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

Related Questions

Where is the general Rigidbodies Drag? 3 Answers

Wrong gravity calculation? 2 Answers

Gliding vs bad acceleration dilema 0 Answers

Gravity suddenly started working very slowly 1 Answer

Instantiated prefab changes gravitational speed when dragged? 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