Unity 5.6 - adding a TrueSync.TSRigidbody2D

"Can't add script behaviour TSCollider2D. The script class can't be abstract!
        var tsrb = gObj.GetComponent<TrueSync.TSRigidBody2D>();
        if ( tsrb == null )
            tsrb = gObj.AddComponent<TrueSync.TSRigidBody2D>();
            tsrb.drag = 0;
            tsrb.mass = 1.0f;
            tsrb.interpolation = TrueSync.TSRigidBody2D.InterpolateMode.Interpolate;
            tsrb.freezeZAxis = true;
            tsrb.velocity = TrueSync.TSVector2.zero;
is Unity 5.6 not supported yet?


  • Xelnath
    edited April 2017
    Formatting fixed. I was trying to add TrueSync objects dynamically but it seems to not be working in either code or the unity editor - same message about abstract classes.
  • Hi @Xelnath, in case of colliders you have to choose some implementation like a box or circle collider. The TSCollider2D is just a parent abstract class that cannot be used directly.
  • I had the same problem... my solution

    - Add TSBoxCollider2d or TSCircleCollider2d first ( note, you seem to have to drag the actual script from /TrueSync/Unity onto the gameobject, as for some reason this script no longer appears in the "Add Component" button);

    - Add TSRigidbody in the same way.
  • Hi @feathers, this scripts no longer appeared after you update to TrueSync 1.1.0 or do your noticed a possible reason?
  • I was able to dynamically generate new collider boxes with the following code:

    public GameObject AddCollisionDetectionBox( string name, Bounds bounds )
    var debugObj = new GameObject( name );
    debugObj.transform.SetParent(transform, false);
    debugObj.gameObject.layer = transform.gameObject.layer;
    TSTransform2D tsTransform = debugObj.GetOrAddComponent();
    TSBoxCollider2D tsBox = debugObj.AddComponent();
    tsBox.isTrigger = true;
    tsBox.size = new TSVector2(bounds.size.x,bounds.size.y);
    tsBox.Center = new TSVector2(bounds.center.x,bounds.center.y);
    tsBox.tsTransform.tsParent = this.tsTransform2D;
    tsBox.tsTransform.position = this.tsTransform2D.position;
    TSRigidBody2D tsRigid = debugObj.AddComponent();
    tsRigid.isKinematic = true;
    tsBox.attachedRigidbody = tsRigid;

    return debugObj;