• 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 /
avatar image
0
Question by enestezi · Oct 13, 2016 at 08:57 AM · 2drotatesimulationmousewheeldragrigidbody

Dragging and rotating a Rigidbody2D (Limbs with HingeJoint). Shadow Play / Puppetry Simulation

I'm trying to make a program in Unity for playing around with shadow play puppets (mostly "Karagöz"). The characters i want to use made out of jointed limbs. There is a hole on their upperbody which allows to use sticks to move them behind curtain and rotate the bodies: Example1

I build the 2D characters with HingeJoints to simulate how they actually move. i think best way to move them is using mouse. You can drag them with mouse and use the scroll wheel to rotate the bodies. alt text I put a circle collider on the hole of the character and used a similar script like this one to drag my character. My problem is the dragRigidbody2D solutions based on using a spring joint, and its just too springy for my usage and doesnt allow me to use rotating from the same point. I think its same for the TargetJoint2D. I made a little test and it looks way too springy too.

Has anyone an idea how to achive dragging and rotating 2D Rigidbodies with Hingejoints from this certain hole without making it springy / bouncey?

karagoz-theatre-06315.jpg (418.1 kB)
Comment
Add comment · Show 7
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 b1gry4n · Oct 13, 2016 at 12:24 PM 1
Share

Are your "puppets" set upcorrectly as far as hierarchy? By that i mean, the hand is a child of the arm, which is a child of the shoulder, which is a child of the chest, etc? The top most parent should be the "root". If you are unfamiliar with rigging a model, check out any 3d model that is provided for free on the asset store (unity kyle) and look at the bone hierarchy. I understand you are working in 2d space, but the concept is the same. This way, when you move a parent joint, the children joints inherit the parent properties and adjust themselves in local space accordingly.

avatar image enestezi b1gry4n · Oct 13, 2016 at 03:16 PM 0
Share

Yes, they are correctly set up. Two legs attached to hip and hip attached to upper body. Legs are children of the hip and hip is children of the upper body. $$anonymous$$iddle point of the upperbody is placed on the hole to move them from that point. It helped me to add the target/spring joint exactly at that hole. $$anonymous$$y question is: how can I move/drag the body staticly, not bouncy as if they are hold by an elastic string. There must be way, which allows to move the puppet as if I hold them with the sticks like in the picture above staticly and rotate them like the rolling the sticks back and fort.

avatar image b1gry4n enestezi · Oct 13, 2016 at 04:08 PM 0
Share

is there any way you can show me what you mean? With joints I am assuming you want the classic "puppet" effect where the limbs are dangling and swinging around. Do you mean the joints become "disconnected" and pop back into place? Or do you mean they rotate freely?

Show more comments
avatar image enestezi · Oct 14, 2016 at 01:42 PM 0
Share

@b1gry4n @ianjgrant here we go:

an example about how it should move

an another example with challenging movements

The project is here: github-link additionally i added a video about what i meant.

i think its quite important to specify what i asked. you can see i used a spring joint, and i would like to drag the puppets without spring effect, without bouncing around. so:

Q1: is there a way for dragging such rigidbodies without usage of a spring joint? (for static movements)

Q2: if i have to use a joint to drag them, then how can i implement target joint with a script so that i can move "target" with mouse? (basically, how can i implement targetjoint?)

Q3: how can i rotate the body back and fort with mousewheel -while i drag it with mouse simultaneously- ?

thank you all very much!

avatar image b1gry4n enestezi · Oct 14, 2016 at 09:12 PM 0
Share

While the movements you are after might seem simple, its actually kind of complex. I notice that the feet are planted with knees bending, backs bending, heads and arms are loosely connecting. This all reminds me of inverse kinematics. Something you want isnt exactly rotating the joints themselves, but having control nodes that represent parts of the body. It is standard practice in 3D animation to create a rig for the 3D model. Check out this video to understand what I am talking about. https://youtu.be/uQFzqI3WO7I?t=35s

The reason is, its tedious and more difficult to select and rotate joints/bones, so a controller is made. I think this is something you would want to do as well. If you look at it, the idea is super similar. 3D animation is a lot like recording a puppet moving. Like I said before, I understand youre aiming for 2D, but the idea behind what you want is extremely similar to what I just mentioned.

Take a look at these unity assets. They might give you some ideas.

https://www.assetstore.unity3d.com/en/#!/content/48977. https://www.assetstore.unity3d.com/en/#!/content/14290

And, unity does have inverse kinematics (I$$anonymous$$), but as a pro only feature : https://docs.unity3d.com/$$anonymous$$anual/Inverse$$anonymous$$inematics.html

Again, I realize this is aimed at 3d, but you can for sure use it in 2D space if set up properly. This is the type of stuff you will want to implement and use in your project. So what you would do is have the controllers, or effectors, be the things you are moving/controlling and they influence the joints/bones associated.

avatar image enestezi b1gry4n · Oct 19, 2016 at 12:59 PM 0
Share

do you think so. actually its kinda simple how the puppets built. every limb attached to another with simple strings like a chain and they move like hinge joint without limitation. the moves wich you see are just talent of the puppet artist making simple puppets looks so strong on expression. At this state i ignore the secondary control instances like that one arm. i hope to move it later with keybord (direction buttons).

believe me or not, what you see is just good artistic use of this stick i explained already. he rotates and "drags" the puppet and illusion is there.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ianjgrant · Oct 13, 2016 at 11:19 PM

HI,

I have a lot of experience solving this problem with my performance animation / multitouch 'ShadowEngine' part-time PhD project. I collected 200+ images of Karagöz figures from European museums to use in the system.

alt text

The script you reference sets up a generic 'dragging' spring joint with default settings that pulls the hit rigidbody around.

Plenty of designs / approaches will achieve what you are after. My latest attempt experiments with how many touch controls are useable (in a HCI sense - mine is a multitouch context not just mouse control. Interestingly, mouse control is sometimes more effective / expressive thank multitouch when operated live). In the image below - each coloured drag zone is a 'fixed' hotspot and has different 'spring' settings attached to the local rigidbodies. Some controls are parented to another that when it rotates you get a 'marionette' controller effect which is very nice. Double click = rotate puppet to face the other direction (I tween the x scale). When using an iPad - this object rotates nicely around anchored finger points (in the XY plane). An effect I've been looking for for ages.

alt text

One thing worth trying: a distance joint is a spring joint with the freq.= 0 and damp. ratio = 1 (I think). Play with those settings in the controlling spring object. I've thought it a good idea to expose the spring settings to edit them at runtime to get the right balance for each puppet. See the following thread - where I'm trying to create a generic UI for this: unity answers thread

You do have to iterate a lot with settings for the joints and rigidbody properties. e.g. Rigidbody: The mass of each object in the hierarchy matters as do the drag values.

It is easy to freak out the physics in these set ups. So finding 'balance' in the system is a careful act of tweaking settings...

I hope this helps. Do PM me as I'm interested in every digital puppety project I find.

Question: what 'body' do you rotate with the mouse?

Kind regards, Ian


screen-640x480-2016-10-12-22-31-53.png (317.9 kB)
iim-spreads.jpg (448.6 kB)
Comment
Add comment · 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 enestezi · Oct 19, 2016 at 01:03 PM 0
Share

Hi, Thank you very much for your answer. I actually read and watch everything you made :) and I wanted to contact you after I have something to share.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I Rotate a 2D object (sprite) so that it causes another to rotate? 2 Answers

How to rotate around the parent in 2D? 1 Answer

Rotating a 2D GameObject on Z regardless of the distance. 2 Answers

Rotating Around Joints 0 Answers

How can I rotate my player to look at the direction my Joystick is pointing to? (Top-Down 2D) 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges