• 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 /
avatar image
Question by Asherian · Dec 14, 2017 at 11:50 AM · scripting problemphysicsscriptableobjectinputfielddropbox

Is there a way to set the mass of a gameobject without using the Rigidbody component??

I need to set the mass of different gameobjects at the start of my program by using the input boxes in the scene, at the moment I have 2 input boxes (acceleration and mass) and a dropdown box (object type) but I do plan to add more as my project develops. All the research I've done states to use rigidbody but as it is project work that simulates Newtonian physics I've been told I can't use the basic unity physics as it would bring down the grade of my project which is why I can't use rigidbody. So is there anyway I can add mass to the object and also is there a way to find the centre of mass of the object without using unity's physics engine? I don't quite understand how the message calling system works so if that is how it should be done I'd be really appreciative if someone gave me a quick run through as I'll have to do this for multiple inputs.

Comment

People who like this

0 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 nt314p · Dec 20, 2017 at 12:31 AM 0
Share

What do you mean it would bring down the grade of your project??

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by KittenSnipes · Dec 14, 2017 at 01:29 PM

Well mass = force / acceleration. So simply calculate force and acceleration. Then calculate mass.

Here’s how to calculate acceleration:

 //Java Implementation
 
 var lastVelocity : Vector2;
 
 function Update()
 {
     var acceleration = (velocity - lastVelocity) / Time.deltaTime;
     lastVelocity = velocity;
 }
 
 //C# Implementation
 Vector2 lastVelocity;
 
 void Update()
 {
     float acceleration = (velocity - lastVelocity) / Time.deltaTime;
     lastVelocity = velocity;
 }
 
 

Not to sure how you are implementing force so I can’t give a clear answer for that. Even though that’s a way to calculate acceleration you still need velocity which so happen rigid body simulates. So you have a bit of work ahead of you.

Comment

People who like this

0 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 Bunny83 · Dec 14, 2017 at 02:35 PM 0
Share

Sorry but this is pretty pointless ^^. The mass of an object is a property of the object itself. He actually want to assign a certain mass to his object since the mass doesn't change. The acceleration depends on the applied force and the objects mass.

avatar image

Answer by Bunny83 · Dec 14, 2017 at 02:45 PM

Well, if you don't use Unity's physics system you just have to "store" the mass in one of your variables. Since you want to roll your own physics you have to keep track of an objects properties (for a rigidbody the static infomation is the mass, the center of mass, the inertia tensor as well as any form parameters like drag). Note that i talk about Rigidbodies in general, not Unity's rigidbody component.


Simulating proper newtonian physics can be quite complicated. It's not clear if you actually use another third party physics engine or if you actually want to roll your own. If you use a thrid party physics engine it should have means to set the mass of an object. If you roll your own, just declare a variable like

 public float mass;

And assign a value. Of course in the actual equations when you calculate the required acceleration from a given force you have to use that value.


Since this seems to be "homework" i will move the question into the help room.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Strange UnMathematical Results for Physics System 0 Answers

Looking for Drag and Drop Zone (snapping) scripts for Physics objects, not UI 0 Answers

How to make sphere 'stick' to inside of hollow cylinder 0 Answers

How can I fix my jumping script? 0 Answers

Physics object bouncing on collision. 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