Hinge Joint 2D
Options
Hello,
I need 2d hinge joint in true sync, please give me some idea or information about implement 2d hinge joint in true sync
Thanks
I need 2d hinge joint in true sync, please give me some idea or information about implement 2d hinge joint in true sync
Thanks
0
Comments
-
Hi @UnityGames, I suggest you to search about how to do it in Farseer Physics, we have open sourced the code so you can try out.0
-
I try it but it seem to not run exactly:
public override void OnSyncedStart ()
{
base.OnSyncedStart ();
tsRigidBody2D.useGravity = true;
World world = (World)Physics2DWorldManager.instance.GetWorld();
if(refAnchorObj != null){
TSTransform2D anchorTrans = refAnchorObj.GetComponent ();
Body a = (Body)anchorTrans.tsCollider.Body;
Body b = (Body)tsRigidBody2D.tsCollider.Body;
PrismaticJoint joint = JointFactory.CreatePrismaticJoint (world, a, b,TSVector2.zero,TSVector2.up);
joint.LimitEnabled = true;
joint.SetLimits (-10, 10);
joint.CollideConnected = false;
joint.MotorSpeed = 1000;
joint.MotorEnabled = true;
joint.MaxMotorForce = 1000;
joint.Enabled = true;
}
else{
Debug.Log ("refAnchorObj null;");
}
}
public override void OnSyncedUpdate ()
{
base.OnSyncedUpdate ();
World world = (World)Physics2DWorldManager.instance.GetWorld();
Debug.Log ("world count: "+world.JointList.Count);
}
0 -
Hi @ttcong194, what happened? you didn't get a prismatic behaviour? By the wasy we only implement a version of HingeJoint, prismaticjoin is not support by this time for us.0