Search Unity

How to make two object parallel

Discussion in 'Scripting' started by LMC008, Aug 4, 2011.

  1. LMC008

    LMC008

    Joined:
    May 20, 2011
    Posts:
    23

    let say i has two object like picture A. And i need move the cube toward the capsule and it is require cube is parellel to the capsule. (like B)

    How to do it? i had success moved the cube to the capsule, but i can not figure out how to make the cube parallel with the capsule.

    thanks you in advise
     
  2. ar0nax

    ar0nax

    Joined:
    May 26, 2011
    Posts:
    485
    on the cube use the next part of code:
    Code (csharp):
    1.  
    2. transform.rotation = target.transform.rotation;
    3.  
    target is the capsule.
     
  3. LMC008

    LMC008

    Joined:
    May 20, 2011
    Posts:
    23
    this is not working on my case. Actually my object is quite more complicated(got parent and children), i am just use cube and capsule to represent my actual object. Hopefully i can get some idea on make two object parallel.
     
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Define: "not working", "quite more complicated".
     
  5. ar0nax

    ar0nax

    Joined:
    May 26, 2011
    Posts:
    485
    well if you havea a human model, parent it to another empty gameobject (if you have animations and such) and apply the same line of code on the empty gameobject, and on the model (which is parented to the empty gameobj) every other script you might need on it.

    so it will play animations and such, and the empty gameobject will rotate to be parallel to your target, and it will rotate your model as well.
     
  6. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    I, and other people are probably confused by your example.

    Could you tell us the purpose of attaching multiple scripts to every portion of a model instead of iterating through the model and doing your solver there?

    If you have a human model, are you wanting a series of game objects that will mimic the animations of that human? What is the purpose? Is it to apply weapons, armor or other modifications to it?
     
  7. LMC008

    LMC008

    Joined:
    May 20, 2011
    Posts:
    23


    well let me define "quite more complicated" with the picture above.
    Actually i use
    cube=hand
    capsule = "that thing" call jig

    I wish the right hand can move and parallel to the body of the jig.
    so i can grasp it and manipulate the jig.