Search Unity

Technical Questions (Gravity, Collisions, Attachement, etc)

Discussion in 'General Discussion' started by Dranore, Jun 1, 2007.

  1. Dranore

    Dranore

    Joined:
    May 23, 2007
    Posts:
    57
    I had some technical questions that relate to some ideas for some projects I'd like to try. Feel free to anwser any question you feel like you have the answer to - you don't have to hit em all. ;)

    How does Unity or rather Ageia handle gravity? Can apply different physics handling per object? Can you change the direction of gravity in runtime?

    Can you make changes to the collision model dynamically? For example, say you have a character that has to carry a very large stact of objects and you don't want to have to track each an every object contstantly, so instead you increase the height of the playercharacter's collision box in runtime instead?

    How does object attachement work (meaning attaching one model to another)? Can it be done dynamically? I've looked through the documentation and had trouble finding a clear answer.

    I have a lot of interest in generative content. How much control do you have over objects within the game at runtime? Can you programatically create and destroy them? Say, for a simplistic example, I want to make a maze or something made up of different sections models and I want to change the sections around in runtime based on users actions.

    Is it possible to constrain/attach model movement to paths/rails, for say a rail shooter or other creative options?

    Thanks again for the help.
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Gravity is just a force that is applied to all the objects. Gravity vector can be changed at runtime via Physics.gravity, and it can be turned on/off on each rigibody via rigidbody.useGravity property. If you want to apply different gravity to some rigidbody, then turn off default one and repeatedly apply some force yourself.

    Sure, BoxCollider.size, CapsureCollider.height and so on.

    You parent their transforms. Attached (child) object the "follows" the parent one. Just assign the transform.parent variable.

    A lot! :)
    Instantiate used in conjunction with Prefabs is your friend. Of course you can also dynamically create meshes and generate textures (for that see Procedural example project).

    Sure. Just write some code that changes object's position/rotation based on whatever you like. Or do animation in 3D app and let Unity's animation system do that for you.

    By the way, I think most of these types of questions are covered by the tutorials, and answers to scripting questions can often be found by using Search box on the left of scripting reference page (e.g. type "gravity" and go).