// Use this for initialization void Start() { fix = gameObject.AddComponent <LPFixturePoly>(); fix.DefinePoints(Points); bod = GetComponent <LPBody>(); bod.Initialise(FindObjectOfType <LPManager>()); }
// Use this for initialization void Start() { fix = gameObject.AddComponent<LPFixturePoly>(); fix.DefinePoints(Points); bod = GetComponent<LPBody>(); bod.Initialise(FindObjectOfType<LPManager>()); }
static void Setupdynamics(GameObject ob) { Rigidbody2D rigidb = ob.GetComponent <Rigidbody2D>(); if (rigidb) { LPBody bod = ob.GetComponent <LPBody>(); if (rigidb.isKinematic) { bod.BodyType = LPBodyTypes.Kinematic; } else { bod.BodyType = LPBodyTypes.Dynamic; } bod.LinearDamping = rigidb.drag; bod.AngularDamping = rigidb.angularDrag; bod.GravityScale = rigidb.gravityScale; bod.FixedRotation = rigidb.fixedAngle; if (rigidb.collisionDetectionMode == CollisionDetectionMode2D.Continuous) { bod.IsBullet = true; } if (rigidb.sleepMode == RigidbodySleepMode2D.NeverSleep) { bod.AllowSleep = false; } Undo.DestroyObjectImmediate(rigidb); } }
public bool isFixtureStatic() { if (body == null) { body = GetComponent <LPBody>(); } return(body.BodyType == LPBodyTypes.Static); }
void Start() { bod = GetComponent<LPBody>(); lpman = FindObjectOfType<LPManager>(); if (lpman.UseContactListener == false) { Debug.LogError("This body destroyer needs 'Use Contact Listener' in the LPManager component in this scene to be set to reue in order to work"); } }
public void SetupBody() { body = GetComponent <LPBody>(); if (body == null) { body = gameObject.AddComponent <LPBody>(); //body.Initialise(lpManager); } }
void Start() { bod = GetComponent <LPBody>(); lpman = FindObjectOfType <LPManager>(); if (lpman.UseContactListener == false) { Debug.LogError("This body destroyer needs 'Use Contact Listener' in the LPManager component in this scene to be set to reue in order to work"); } }
protected override void DoSpawn() { GameObject ob = Instantiate(Prefab, transform.position, Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.back)) as GameObject; LPBody bod = ob.GetComponent <LPBody>(); bod.Initialise(lpman); Vector3 diff = getdiff(); LPAPIBody.ApplyLinearImpulseToBody(bod.GetPtr(), diff.x, diff.y, ob.transform.position.x, ob.transform.position.y, true); }
/// <summary>Create this fixture in the simulation</summary> public virtual void Initialise(LPBody bod) { body = bod; myIndex = body.AddFixture(this); GetPhysProps(); IntPtr shape = GetShape(); ThingPtr = LPAPIFixture.AddFixture(body.GetPtr(),(int)Shapetype ,shape ,Density,actualFriction,actualRestitution,IsSensor,myIndex); LPAPIFixture.SetFixtureFilterData(ThingPtr,(Int16)CollisionGroupIndex,categoryBits,maskBits); }
/// <summary>Create this fixture in the simulation</summary> public virtual void Initialise(LPBody bod) { body = bod; myIndex = body.AddFixture(this); GetPhysProps(); IntPtr shape = GetShape(); ThingPtr = LPAPIFixture.AddFixture(body.GetPtr(), (int)Shapetype , shape , Density, actualFriction, actualRestitution, IsSensor, myIndex); LPAPIFixture.SetFixtureFilterData(ThingPtr, (Int16)CollisionGroupIndex, categoryBits, maskBits); }
void MakeChainFix() { //Add an LPFixtureChainShape to the gameobject (LPBody is required so is added automatically) LPFixtureChainShape fix = ChainFix.AddComponent <LPFixtureChainShape>(); //Call DefinePoints to set the polys points programmatically fix.DefinePoints(Points); //Set up the body how we want LPBody bod = ChainFix.GetComponent <LPBody>(); bod.BodyType = LPBodyTypes.Dynamic; //Call initialise on the LPBody component passing in the LPManager component bod.Initialise(FindObjectOfType <LPManager>()); }
// Update is called once per frame void Update() { bool aTouch = false; Vector3 touchPos = new Vector3(); InputUtilities.GetMouseInput(out aTouch, out touchPos); if (aTouch) { if (ClickedBody == null) // If we have not clicked on a body yet { Vector3 mousePos = touchPos; mousePos = Camera.main.ScreenToWorldPoint(mousePos); ClickedBody = lpMan.TestPointForBody(mousePos.x, mousePos.y); } } else { ClickedBody = null; } }
private IEnumerator Spawn() { while (true) { if (bodylist.Count > amount) { bodylist[0].Delete(); bodylist.RemoveAt(0); } GameObject go = new GameObject("body"); go.transform.parent = transform; go.transform.position = transform.position; LPBody body = go.AddComponent <LPBody>(); bodylist.Add(body); LPFixtureCircle circle = go.AddComponent <LPFixtureCircle>(); circle.Density = 0.2f; circle.Radius = 0.1f; body.BodyType = LPBodyTypes.Dynamic; body.Initialise(lpman); LPAPIBody.ApplyForceToCentreOfBody(body.GetPtr(), SpawnVelocity.x, SpawnVelocity.y); yield return(new WaitForSeconds(spawninterval)); } }
/// <summary> /// Pass an LPBody in here after creation to add it to the list of all the bodies in the world and assign it an index</summary> public int AddBody(LPBody body) { allBodies.Add(bodiesIndex,body); bodiesIndex++; return bodiesIndex -1; }
void Start() { lpman = FindObjectOfType<LPManager>(); bod = GetComponent<LPBody>(); }
// Use this for initialization void Start() { partsys = FindObjectOfType<LPParticleSystem>(); bod = GetComponent<LPBody>(); }
// Use this for initialization void Start() { partsys = FindObjectOfType <LPParticleSystem>(); bod = GetComponent <LPBody>(); }
/// <summary> /// Pass an LPBody in here after creation to add it to the list of all the bodies in the world and assign it an index</summary> public int AddBody(LPBody body) { allBodies.Add(bodiesIndex, body); bodiesIndex++; return(bodiesIndex - 1); }
void Start() { lpman = FindObjectOfType <LPManager>(); bod = GetComponent <LPBody>(); }