public void SetTarget(Vector3 target) { if ((transform.position - target).magnitude > Accuracy) { LPAPIJoint.SetMouseJointTarget(ThingPtr, target.x, target.y); } }
protected override void Initialise2(IntPtr world) { bool isArev = false; bool isBrev = false; if (JointA != null && JointB != null && (JointA.GetType() == typeof(LPJointRevolute) || JointA.GetType() == typeof(LPJointPrismatic)) && (JointB.GetType() == typeof(LPJointRevolute) || JointB.GetType() == typeof(LPJointPrismatic))) { if (JointA.GetType() == typeof(LPJointRevolute)) { isArev = true; } if (JointB.GetType() == typeof(LPJointRevolute)) { isBrev = true; } ThingPtr = LPAPIJoint.CreateGearJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , JointA.GetPtr(), isArev, JointB.GetPtr(), isBrev, Ratio, CollideConnected); } else { Debug.LogError("This Gear Joint must be assigned 2 Other Joints in order to be created" + ", also both joints need to be a type of either LPJointRevolute or LPJointPrismatic"); } }
void FixedUpdate() { for (int i = 0; i < 8; i++) { float Ldistance = LPAPIJoint.GetDistanceJointLength(LeftMuscle[i].GetPtr()); float Rdistance = LPAPIJoint.GetDistanceJointLength(RightMuscle[i].GetPtr()); float act = Ldistance - LeftMuscleForce[i]; if (act < 0) { act = 0; } if (act < 10) { act += relax; } LPAPIJoint.SetDistanceJointLength(LeftMuscle[i].GetPtr(), act); LeftMuscleForce[i] = 0; act = Rdistance - RightMuscleForce[i]; if (act < 0) { act = 0; } if (act < 10) { act += relax; } LPAPIJoint.SetDistanceJointLength(RightMuscle[i].GetPtr(), act); RightMuscleForce[i] = 0; } }
protected override void Initialise2(IntPtr world) { Vector3 anchorA = transform.position - BodyA.transform.position; Vector3 anchorB = transform.position - BodyB.transform.position; ThingPtr = LPAPIJoint.CreateWeldJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , anchorA.x, anchorA.y, anchorB.x, anchorB.y, CollideConnected); }
protected override void Initialise2(IntPtr world) { ThingPtr = LPAPIJoint.CreateMouseJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , BodyB.transform.position.x, BodyB.transform.position.y, true); LPAPIJoint.SetMouseJointMaxForce(ThingPtr, MaximumForce); LPAPIJoint.SetMouseJointDampingRatio(ThingPtr, DampingRatio); LPAPIJoint.SetMouseJointFrequency(ThingPtr, Frequency); }
protected override void Initialise2(IntPtr world) { //float lenght = (BodyA.transform.position-BodyB.transform.position).magnitude; ThingPtr = LPAPIJoint.CreateDistanceJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , BodyAAnchorOffset.x, BodyAAnchorOffset.y , BodyBAnchorOffset.x, BodyBAnchorOffset.y, lenght, CollideConnected); LPAPIJoint.SetDistanceJointDampingRatio(ThingPtr, Dampingratio); LPAPIJoint.SetDistanceJointFrequency(ThingPtr, FrequencyInHertz); }
protected override void Initialise2(IntPtr world) { Vector3 anchorA = Vector3.zero; Vector3 anchorB = Vector3.zero; ThingPtr = LPAPIJoint.CreateFrictionJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , anchorA.x, anchorA.y, anchorB.x, anchorB.y, CollideConnected); LPAPIJoint.SetFrictionJointMaxForce(ThingPtr, MaximumForce); LPAPIJoint.SetFrictionJointMaxTorque(ThingPtr, MaximumTorque); }
private IEnumerator UpandDown() { while (true) { if (Random.Range(0, 2) == 1) { LPAPIJoint.SetPrismaticJointMotorSpeed(joint.GetPtr(), Random.Range(-3f, 3f)); } yield return(new WaitForSeconds(2f)); } }
protected override void Initialise2(IntPtr world) { Vector3 groundA = (transform.position + new Vector3(BodyAGroundOffset.x, BodyAGroundOffset.y)); Vector3 groundB = (transform.position + new Vector3(BodyBGroundOffset.x, BodyBGroundOffset.y)); float lenghtA = (BodyA.transform.position - groundA).magnitude; float lenghtB = (BodyB.transform.position - groundB).magnitude; ThingPtr = LPAPIJoint.CreatePulleyJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , groundA.x, groundA.y, groundB.x, groundB.y , BodyAAnchorOffset.x, BodyAAnchorOffset.y , BodyBAnchorOffset.x, BodyBAnchorOffset.y, ratio, lenghtA, lenghtB, CollideConnected); }
protected override void Initialise2(IntPtr world) { Vector3 anchorA = transform.position - BodyA.transform.position; Vector3 anchorB = transform.position - BodyB.transform.position; ThingPtr = LPAPIJoint.CreateWheelJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , anchorA.x, anchorA.y, anchorB.x, anchorB.y, Axis.x, Axis.y, CollideConnected); LPAPIJoint.SetWheelJointSpringFrequency(ThingPtr, SpringFrequency); LPAPIJoint.SetWheelJointSpringDampingRatio(ThingPtr, SpringDampingRatio); if (HasMotor) { LPAPIJoint.EnableWheelJointMotor(ThingPtr, HasMotor); LPAPIJoint.SetWheelJointMaxMotorTorque(ThingPtr, MaxMotorTorque); LPAPIJoint.SetWheelJointMotorSpeed(ThingPtr, MotorSpeed); } }
IEnumerator dostuff() { while (on) { nowtime += Time.deltaTime; if (nowtime >= StopTime) { foreach (LPParticleSpawner spawner in Spawners) { spawner.StopSpawning(); } } if (nowtime >= StartTime) { LPAPIJoint.SetRevoluteJointMotorSpeed(joint.GetPtr(), 15f); on = false; } yield return(null); } }
protected override void Initialise2(IntPtr world) { Vector3 anchorA = transform.position - BodyA.transform.position; Vector3 anchorB = transform.position - BodyB.transform.position; ThingPtr = LPAPIJoint.CreateRevoluteJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , anchorA.x, anchorA.y, anchorB.x, anchorB.y, CollideConnected); if (HasMotor) { LPAPIJoint.EnableRevoluteJointMotor(ThingPtr, HasMotor); LPAPIJoint.SetRevoluteJointMaxMotorTorque(ThingPtr, MaxMotorTorque); LPAPIJoint.SetRevoluteJointMotorSpeed(ThingPtr, MotorSpeed); } if (HasLimits) { LPAPIJoint.EnableRevoluteJointLimits(ThingPtr, HasLimits); LPAPIJoint.SetRevoluteJointLimits(ThingPtr, LowerLimit * Mathf.Deg2Rad, UpperLimit * Mathf.Deg2Rad); } }
protected override void Initialise2(IntPtr world) { getbackfor(); RotateTranslation(); Vector3 anchorA = transform.position - BodyA.transform.position; Vector3 anchorB = transform.position - BodyB.transform.position; ThingPtr = LPAPIJoint.CreatePrismaticJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , anchorA.x, anchorA.y, anchorB.x, anchorB.y, Translation.x, Translation.y, CollideConnected); if (HasMotor) { LPAPIJoint.EnablePrismaticJointMotor(ThingPtr, HasMotor); LPAPIJoint.SetPrismaticJointMaxMotorForce(ThingPtr, MaxMotorForce); LPAPIJoint.SetPrismaticJointMotorSpeed(ThingPtr, MotorSpeed); } if (HasLimits) { LPAPIJoint.EnablePrismaticJointLimits(ThingPtr, HasLimits); LPAPIJoint.SetPrismaticJointLimits(ThingPtr, LowerLimit, UpperLimit); } }
protected override void Initialise2(IntPtr world) { ThingPtr = LPAPIJoint.CreateRopeJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr() , BodyAAnchorOffset.x, BodyAAnchorOffset.y, BodyBAnchorOffset.x , BodyBAnchorOffset.y, MaximumLenght, CollideConnected); }
/// <summary>Delete this joint, in the simulation and in unity</summary> public override void Delete() { LPAPIJoint.DeleteJoint(lpman.GetPtr(), ThingPtr); Destroy(this); }