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 /
  • Help Room /
This question was closed Feb 15, 2016 at 03:39 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by xyHeat · Feb 15, 2016 at 12:52 PM · rigidbodygravitycar

GameObject fall Slowly [C#]

Hey eveybody ! Today i'm making a car. Alls my 3D gameObjects are in an Empty GameObject who have the rigidbody (with 1000 in Mass) and my playerControler. But the fact is that my GameObject fall very Slowly and i check on the internet but nothing work....

this is my script :

using UnityEngine; using System.Collections; using UnityEngine.Networking;

public class PlayerControler : NetworkBehaviour { Transform trans; // Used to cache the transform Rigidbody body; // Used to cache the RigidBody float hInput; float vInput; float rotationSpeed = 90f; // float fallVelocity; public GameObject phareGauche; public GameObject phareDroit;

 void Awake()
 {
     trans = transform;
     body = GetComponent<Rigidbody>();
 }

 // Update is called once per frame
 void Update()
 {
     if (isLocalPlayer == false) return;// Don't check input if this isn't running
                                        // on the local player object


     /*fallVelocity = gameObject.GetComponent<Rigidbody>().velocity.z;
     gameObject.GetComponent<Rigidbody>().velocity += Vector3.down * fallVelocity;*/

     if (Input.GetAxis("Vertical") < 0)
     {
         phareDroit.GetComponent<Renderer>().material.color = new Color(255f, 142f, 0f);
         phareGauche.GetComponent<Renderer>().material.color = new Color(255f, 142f, 0f);
     } else
     {
         phareDroit.GetComponent<Renderer>().material.color = new Color(214f, 217f, 224f);
         phareGauche.GetComponent<Renderer>().material.color = new Color(214f, 217f, 224f);
     }

     hInput = Input.GetAxis("Horizontal");
     vInput = Input.GetAxis("Vertical");
 }

 void FixedUpdate()
 {
     if (isLocalPlayer == false) return;// Don't check input if this isn't running
                                        // on the local player object
                                        // Remove unwanted forces resulting from collisions
     body.velocity = Vector3.zero;
     body.angularVelocity = Vector3.zero;

     // Handle rotation
     var rot = body.rotation.eulerAngles;
     rot.y += hInput * rotationSpeed * Time.deltaTime;
     body.MoveRotation(Quaternion.Euler(rot));

     // Handle forward movement
     body.MovePosition(body.position + vInput * trans.forward * 5f * Time.deltaTime);
 }

}

Thank you, bye !

Comment
Add comment · Show 2
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 meat5000 ♦ · Feb 15, 2016 at 12:57 PM 0
Share

This is a sign that the scale of everything is too large.

avatar image xyHeat meat5000 ♦ · Feb 15, 2016 at 01:23 PM 0
Share

$$anonymous$$aybe, it is a car in a town (some blocks are greater than 100 units)

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by tanoshimi · Feb 15, 2016 at 01:01 PM

Your code is somewhat confusing - you're using rigidbodies which suggests you want to let the physics engine calculate the simulation, but then you're overriding the physics engine on every step by setting:

 body.velocity = Vector3.zero;
 body.angularVelocity = Vector3.zero;

and then manually calculating the movement and rotation of the object....?

You need to pick one approach or the other - if you want to move the object, set the rigidbody to kinematic and calculate all the forces yourself. If you want to use the physics engine, don't then override it.

Comment
Add comment · Show 2 · 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 meat5000 ♦ · Feb 15, 2016 at 01:08 PM 0
Share

Lol I didnt read the code. Setting velocity = zero 50 times a second is a sure way to make your objects fall mega slowly.

avatar image xyHeat · Feb 15, 2016 at 01:28 PM 0
Share

Thank you (tanoshimi and meat5000) to answer me very quickly ! So, i deleted this two lines :

body.velocity = Vector3.zero; body.angularVelocity = Vector3.zero;

and it work !

I promise that is my next code i will make more description in case i need some help !

Thank you again, bye !

Follow this Question

Answers Answers and Comments

38 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

Related Questions

What is the best way to calculate the performance stats of a car in a racing game? 1 Answer

I'm making a car system and my car isn't moving even though the wheels are turning. Everything has a RigidBody. I'm using Bolt Visual Scripting. 0 Answers

Copy collision object position (Or just "fly" a little bit) 0 Answers

I added Rigidbody to my cube and now it goes super fast when i move! 0 Answers

Space,Gravity,RigidBody,Physics Forces 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