unity 3d student

Beginner B00 – Adding Mass / Gravity with Rigidbodies


How to add gravity / mass to an object using a Rigidbody component

Further Reading

Share via Social Media

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Add to favorites

16 Comments

    Hello

    I’m using the Unity iPhone 2.6 Editor. It seems the “iPhone standard assets” Box Collider doesn’t include default ‘Physic Material’ options. For example I cannot add bounce. None seems to be my onlyis option.

    How would I get around this issue?

    Thanks.
    Tomo

    • Tomo, presumably this just means the asset isn’t included in iphone standard assets – however you can make them yourself using the Create button on the Project panel, then look at the component reference to figure out how to make a Bouncy Physic material. It’ll be a good exercise to help you figure out making such assets from scratch! good luck!

    Sorry I meant to say in my last post that Unity 2.6 was actually Unity iPhone 1.7.

    Anyway I poked around the scripting reference and found a work around via attaching a script to the cube.

    var bouncyness : float = 1;

    function Start () {
    var mat : PhysicMaterial = collider.material; // short for gameObject.collider…
    mat.bouncyness=bouncyness;
    }

    Cheers
    Tomo

    • Thanks for posting the code! ^^

    I definitely love the format of the tutorial! I’m looking forward to running through a variety of these topics and the challenges as well.

  • just have to say that this is a great website:)

  • Using Unity3….and ‘trying’ to follow this tutorial, but alas; my ‘rigid body’ passes through the ‘floor’ cube every time I press ‘play’?? I add the component to the cube, set to ‘bouncy’, but the rigid body never seems to react with the ‘floor’ cube.

    I enjoy and appreciate these ‘stepped’ tutorials, keep up the great work!

    • is the RB intersecting the floor when the game starts, or do you have the floor collider component set to ‘is trigger’ in the inspector?

      • Solved it somewhat myself by rethinking my approach with typing, “Unity3″….I was using the ‘default’ BootCamp.unity project and a ‘new Scene’…once I ‘restarted’ and generated a ‘new project’ as the tutorials do…my Rigid Bodies are reacting as the tutorial describes!

        …what I get for thinking, ‘advanced’, when I’m just learning to crawl in Unity…been a Torque’master’ for some time now and wanted to start looking at Unity…nice! I likes it! LOL.

        Thanks for the quick reply and offer of assistance, I appreciate that as well!

    Hi Will. I’m second year IMP.

    How do i get the Assets for the bounce? It’s way over my head!

  • don’t worry. figured it out. for anyone else who can’t do it go to: assets -> import package -> applications -> unity -> standard assets -> and it’s the physics materials package not the standard assets (mobile) which was what got me confused

  • I’m using Unity 3.1 with Mobile, and had the same problem with getting the bounce to work. I wrote the following C# code and attached it as a component to my Game Object:

    using UnityEngine;
    using System.Collections;

    public class BounceScript : MonoBehaviour {

    float myBounciness = 1;

    // Use this for initialization
    void Start () {
    PhysicMaterial mat = collider.material;
    mat.bounciness = myBounciness;
    }

    // Update is called once per frame
    void Update () {

    }
    }

  • Nice Work

  • Best Unity tutorial site! =D

  • Fantastic! Just what I need to get me started. I have taught Flash games to high school students for a while. And I’ve figured for some time now that I should be moving into 3D games. We’ve been using Maya for a couple of years, and so combining this with Unity makes a lot of sense. But where to go to get kick started? Wasn’t too long before I found your site. It’s just perfect. Really well taught. Thanks a lot.

    • Great, thanks John :)

Leave a Comment