Ejemplo n.º 1
0
 void FixedUpdate()
 {
     int[] conts = bod.GetContacts();
     if (conts.Length > 1)
     {
         Vector3 diff = getdiff();
         for (int i = 1; i < conts.Length; i++)
         {
             if (lpman.allBodies.ContainsKey(conts[i]))
             {
                 LPAPIBody.ApplyForceToCentreOfBody(lpman.allBodies[conts[i]].GetPtr(), diff.x, diff.y);
             }
         }
     }
 }
Ejemplo n.º 2
0
 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));
     }
 }