Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Softbody ball in 2.5D

Discussion in 'Scripting' started by Leszek, Apr 11, 2011.

  1. Leszek

    Leszek

    Joined:
    Oct 11, 2009
    Posts:
    16
    Hi

    I ' am writing a 2.5d game which player must move a softbody ball.
    I wrote a sample game in BlitzBasic3D in the previous year.

    Now I am building it in unity3d. I have problem with softbody.

    Questions:
    How to lock axis in softbody mesh ? Game is 2.5D and i use X, Y Axis
    How to add a torque a softbody mesh ? Do i have use a attached colliders ?

    Regards,
    Leszek
     
  2. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    softbody? I don't think they exist in Unity. Rigidbody?
     
  3. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    The basics of what you are asking revolve around using a Rigidbody. Look at the documentation for it.

    For locking an axis you are probably looking for angularVeloctiy. You will need to do it during the FixedUpdate so that it maintains it through the physics part.

    As far as colliders, for a ball, you need a sphere collider. If you just make a sphere, it already has that collider attached, if not, you will need to add the SphereCollider component under the Components/Physics dropdown.
     
  4. Leszek

    Leszek

    Joined:
    Oct 11, 2009
    Posts:
    16
    Hi

    In Blitz3D i created something like this ( prototype ): http://www.youtube.com/watch?v=UfDr9eD7wKY

    This softbody ball :)

    In Unity3d i use cloth physics for it.
    How to lock axis in that ball ?

    Any ideas?
    Leszek
     
    Last edited: Apr 11, 2011
  5. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Add a rigidbody to it (if you don't already have one).

    In the inspector you'll see "Constraints" under the Rigidbody, expand this and you'll see:

    Freeze Position: x[] y[] z[]
    Freeze Rotation: x[] y[] z[]

    EDIT:
    This does, of course, assume you are moving the object with the physics engine. If you are moving the object yourself, you'll have to manually constrain it's position/rotation in your movement code.
     
  6. Leszek

    Leszek

    Joined:
    Oct 11, 2009
    Posts:
    16
    Ok I use a Constraints but for the cloth doesn't work ;/

    I should use parent or something like that ?
    Do i have use a attached colliders for cloth ?
    For example: I create a sphere and cloth ball.
    Sphere is parent of cloth ball. Should i am moving a sphere ( parent ) in my game ?

    Sphere
    - > Cloth ball

    But the problem is. When i use a Constraints and attach rigidbody for cloth, my cloth ball moved in all axis (x,y,z)
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Cloth is 3D, it can't be constrained to 2D. You could consider using orth projected camera to fake 2D or you will need to build a spring connected frame to fake it.
     
  8. Leszek

    Leszek

    Joined:
    Oct 11, 2009
    Posts:
    16
    what you mean by saying: build a spring connected frame

    In my unity3d project i use orto camera but i have problem with cloth ball because it's moving on all axis ( x,y,z and rotation )
    In should lock translate.position.z and translate.rotation.x and translate.rotation.y.
    How to lock axis for cloth ?

    Edit;
    I attach a unity3d package
     

    Attached Files:

    Last edited: Apr 12, 2011
  9. Leszek

    Leszek

    Joined:
    Oct 11, 2009
    Posts:
    16
    Hi
    I found a brutal solution :) because I have not found another ;/



    What do you think about that ?
     
  10. Zone

    Zone

    Joined:
    Dec 3, 2010
    Posts:
    59
    @Leszek DUDE ! thanks so fricken much for that package, youre a life saver! :)