/**
         *  @brief Returns the velocity of the body at some position in world space.
         **/
        public TSVector2 GetPointVelocity(TSVector2 worldPoint)
        {
            TSVector directionPoint = (position - tsCollider.Body.TSPosition).ToTSVector();

            return(TSVector.Cross(new TSVector(0, 0, tsCollider.Body.TSAngularVelocity), directionPoint).ToTSVector2() + tsCollider.Body.TSLinearVelocity);
        }
 /**
  *  @brief Simulates the provided tourque in the body.
  *
  *  @param torque A {@link TSVector2} representing the torque to be applied.
  **/
 public void AddTorque(TSVector2 torque)
 {
     tsCollider.Body.TSApplyTorque(torque);
 }
        public void PostStep()
        {
            TSVector2 tSVector = this.childOffset + this.parent.Position;

            this.child.SetTransformIgnoreContacts(ref tSVector, this.child.Rotation);
        }
 /**
  *  @brief Applies the provided force in the body.
  *
  *  @param force A {@link TSVector2} representing the force to be applied.
  *  @param position Indicates the location where the force should hit.
  **/
 public void AddForceAtPosition(TSVector2 force, TSVector2 position)
 {
     AddForceAtPosition(force, position, ForceMode.Impulse);
 }
 public static TSCollider2D[] OverlapCircleAll(TSVector2 i_Point, FP i_Radius, int i_Mask)
 {
     return((TSCollider2D[])_OverlapCircle(i_Point, i_Radius, Physics2D.BodySpecialSensor.ActiveAll, i_Mask));
 }
Exemple #6
0
 /**
  * @brief Instantiates a new prefab in a deterministic way.
  *
  * @param prefab GameObject's prefab to instantiate.
  * @param position Position to place the new GameObject.
  * @param rotation Rotation to set in the new GameObject.
  **/
 public static GameObject SyncedInstantiate(GameObject prefab, TSVector2 position, TSQuaternion rotation)
 {
     return(SyncedInstantiate(prefab, new TSVector(position.x, position.y, 0), rotation));
 }
Exemple #7
0
 /**
  *  @brief Cast a circle and returns an array {@link TSRaycastHit2D} with information about all {@link TSCollider2D} found. Returns null if there is none.
  *
  *  @param origin Origin of the circle in world space.
  *  @param radius Radius of the circle.
  *  @param direction Direction {@link TSVector2} of the cast.
  *  @param distance Max distance to reach.
  **/
 public static TSRaycastHit2D[] CircleCastAll(TSVector2 origin, FP radius, TSVector2 direction, FP distance)
 {
     return((TSRaycastHit2D[])_CircleCast(origin, radius, direction, distance, Physics2D.BodySpecialSensor.ActiveAll));
 }
        public static TSRaycastHit2D[] Raycast(TSVector2 i_Origin, TSVector2 i_Direction, FP i_Distance, int i_Mask)
        {
            Physics2DWorldManager physicsManager = (Physics2DWorldManager)PhysicsManager.Instance;

            return(physicsManager.Raycast(i_Origin, i_Direction, i_Distance, i_Mask));
        }
Exemple #9
0
 /**
  *  @brief Returns all {@link TSCollider2D} within a box area. Returns null if there is none.
  *
  *  @param point Center of the box in world space.
  *  @param size Size of the box.
  *  @param angle Rotation angle in degrees of the box.
  **/
 public static TSCollider2D[] OverlapBoxAll(TSVector2 point, TSVector2 size, FP angle)
 {
     return((TSCollider2D[])_OverlapBox(point, size, angle, Physics2D.BodySpecialSensor.ActiveAll));
 }
Exemple #10
0
 /**
  *  @brief Returns all {@link TSCollider2D} within a capsule area. Returns null if there is none.
  *
  *  @param point Center of the capsule in world space.
  *  @param size Size of the capsule.
  *  @param direction If it is a vertical or horizontal capsule.
  *  @param angle Rotation angle in degrees of the capsule.
  **/
 public static TSCollider2D[] OverlapCapsuleAll(TSVector2 point, TSVector2 size, TSCapsuleDirection2D direction, FP angle)
 {
     return((TSCollider2D[])_OverlapCapsule(point, size, direction, angle, Physics2D.BodySpecialSensor.ActiveAll));
 }
Exemple #11
0
 /**
  *  @brief Returns all {@link TSCollider2D} within a small circular area. Returns null if there is none.
  *
  *  @param point Center of the point in world space.
  **/
 public static TSCollider2D[] OverlapPointAll(TSVector2 point)
 {
     return((TSCollider2D[])_OverlapCircle(point, POINT_RADIUS, Physics2D.BodySpecialSensor.ActiveAll));
 }
Exemple #12
0
 /**
  *  @brief Returns all {@link TSCollider2D} within a rectangular area. Returns null if there is none.
  *
  *  @param pointA Top-left corner of the rectangle.
  *  @param radius Bottom-right corner of the rectangle.
  **/
 public static TSCollider2D[] OverlapAreaAll(TSVector2 pointA, TSVector2 pointB)
 {
     return((TSCollider2D[])_OverlapArea(pointA, pointB, Physics2D.BodySpecialSensor.ActiveAll));
 }
Exemple #13
0
 /**
  *  @brief Returns the first {@link TSCollider2D} within a rectangular area. Returns null if there is none.
  *
  *  @param pointA Top-left corner of the rectangle.
  *  @param radius Bottom-right corner of the rectangle.
  **/
 public static TSCollider2D OverlapArea(TSVector2 pointA, TSVector2 pointB)
 {
     return((TSCollider2D)_OverlapArea(pointA, pointB, Physics2D.BodySpecialSensor.ActiveOnce));
 }
 /**
  *  @brief Moves the body to a new position.
  **/
 public void MovePosition(TSVector2 position)
 {
     this.position = position;
 }
Exemple #15
0
 private static object _OverlapCircle(TSVector2 point, FP radius, Physics2D.BodySpecialSensor sensorType)
 {
     return(OverlapGeneric(new Physics2D.CircleShape(radius, 1), point, sensorType));
 }
 public static TSCollider2D[] OverlapBoxAll(TSVector2 i_Point, TSVector2 i_Size, FP i_Angle, int i_Mask)
 {
     return((TSCollider2D[])_OverlapBox(i_Point, i_Size, i_Angle, Physics2D.BodySpecialSensor.ActiveAll, i_Mask));
 }
Exemple #17
0
 /**
  *  @brief Returns all {@link TSCollider2D} within a circular area. Returns null if there is none.
  *
  *  @param point Center of the circle in world space.
  *  @param radius Radius of the circle.
  **/
 public static TSCollider2D[] OverlapCircleAll(TSVector2 point, FP radius)
 {
     return((TSCollider2D[])_OverlapCircle(point, radius, Physics2D.BodySpecialSensor.ActiveAll));
 }
 private static object _OverlapCircle(TSVector2 i_Point, FP i_Radius, Physics2D.BodySpecialSensor i_SensorType, int i_Mask)
 {
     return(OverlapGeneric(new Physics2D.CircleShape(i_Radius, 1), i_Point, i_SensorType, i_Mask));
 }
Exemple #19
0
    public static Vector2 ToVector2(TrueSync.TSVector2 v3)
    {
        Vector2 ret = new Vector2(v3.x.AsFloat(), v3.y.AsFloat());

        return(ret);
    }
 public static TSCollider2D[] OverlapAreaAll(TSVector2 i_PointA, TSVector2 i_PointB, int i_Mask)
 {
     return((TSCollider2D[])_OverlapArea(i_PointA, i_PointB, Physics2D.BodySpecialSensor.ActiveAll, i_Mask));
 }
 /**
  *  @brief Applies the provided force in the body.
  *
  *  @param force A {@link TSVector2} representing the force to be applied.
  **/
 public void AddForce(TSVector2 force)
 {
     AddForce(force, ForceMode.Force);
 }
Exemple #22
0
 /**
  * @brief Adds a new TSVector2 value.
  **/
 internal void AddTSVector2(byte key, TSVector2 value)
 {
     this.tsVectorTable2[key] = value;
 }
 public ConstraintHierarchy2D(Body parent, Body child, TSVector2 childOffset)
 {
     this.parent      = parent;
     this.child       = child;
     this.childOffset = childOffset;
 }