Advertisement
Guest User

Untitled

a guest
May 30th, 2022
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hi there DenisIsDenis,
  2. Thank you kindly for your answer 🙂 (I have been attempting to add this comment for over a week but something funky is going on with unity's website) I am however having some issues using both of these methods, unfortunately the Object(s) have a lot of colliders within child objects (all the inner parts), so by disabling interaction with the main collider does not disable all these inner component colliders which the player still is able to levitate, I think I will need to do a lot of reworking of these objects and make it so they are just dummy objects (only the outer case without all the inner components) and when they are dropped onto the disassembly table, I could then enable all the inner components for disassembly.
  3.  
  4. As for the moveObjects() method you provided this does unfortunately allow the player to force the objects through walls and other objects, it's okay with light bumps or taps, but if you walk right up-to or force the object up against a wall it will spaz out briefly before popping up on the other side, also using this method it lost the ability to be able to throw objects using momentum and then releasing the object.
  5. I have managed to come up with a messy yet functional solution by associating the objects distance to calculate the amount of force and drag an object has as well as calculating in the different mass types so lighter objects don't flail around like crazy and heavy objects don't dwindle behind.
  6.  
  7. Code provided in next comment due to character limit.
  8.  
  9. Current Code:
  10.  
  11.     void moveObject()
  12.         {
  13.             if (refer.aWC.isMoving && rig.drag != 0)
  14.             {
  15.                 rig.drag = 4f;
  16.             }
  17.             if (isSmallOBJ)
  18.             {
  19.                 if (distance < 0.05f)
  20.                 {
  21.                     if(rig.drag != highDrag && !refer.aWC.isMoving)
  22.                     {
  23.                         rig.drag = highDrag;
  24.                     }
  25.                     Vector3 f = smallDest.position - transform.position;
  26.                     f = f.normalized;
  27.                     f = f * lowForce;
  28.                     rig.AddForce(f);
  29.                     distance = Vector3.Distance(transform.position, smallDest.position);
  30.                 }
  31.                 else if (distance < 0.5f)
  32.                 {
  33.                     if (rig.drag != midDrag && !refer.aWC.isMoving)
  34.                     {
  35.                         rig.drag = midDrag;
  36.                     }
  37.                     Vector3 f = smallDest.position - transform.position;
  38.                     f = f.normalized;
  39.                     f = f * midForce;
  40.                     rig.AddForce(f);
  41.                     distance = Vector3.Distance(transform.position, smallDest.position);
  42.                 }
  43.                 else if (distance < 5f)
  44.                 {
  45.                     if (rig.drag != lowDrag && !refer.aWC.isMoving)
  46.                     {
  47.                         rig.drag = lowDrag;
  48.                     }
  49.                     Vector3 f = smallDest.position - transform.position;
  50.                     f = f.normalized;
  51.                     f = f * highForce;
  52.                     rig.AddForce(f);
  53.                     distance = Vector3.Distance(transform.position, smallDest.position);
  54.                 }
  55.                 else
  56.                 {
  57.                     dropObject();
  58.                 }
  59.             }
  60.             else
  61.             {
  62.                 if (distance < 0.05f)
  63.                 {
  64.                     if (rig.drag != highDrag && !refer.aWC.isMoving)
  65.                     {
  66.                         rig.drag = highDrag;
  67.                     }
  68.                     Vector3 f = dest.position - transform.position;
  69.                     f = f.normalized;
  70.                     f = f * lowForce;
  71.                     rig.AddForce(f);
  72.                     distance = Vector3.Distance(transform.position, dest.position);
  73.                 }
  74.                 else if (distance < 0.5f)
  75.                 {
  76.                     if (rig.drag != midDrag && !refer.aWC.isMoving)
  77.                     {
  78.                         rig.drag = midDrag;
  79.                     }
  80.                     Vector3 f = dest.position - transform.position;
  81.                     f = f.normalized;
  82.                     f = f * midForce;
  83.                     rig.AddForce(f);
  84.                     distance = Vector3.Distance(transform.position, dest.position);
  85.                 }
  86.                 else if (distance < 5)
  87.                 {
  88.                     if (rig.drag != lowDrag && !refer.aWC.isMoving)
  89.                     {
  90.                         rig.drag = lowDrag;
  91.                     }
  92.                     Vector3 f = dest.position - transform.position;
  93.                     f = f.normalized;
  94.                     f = f * highForce;
  95.                     rig.AddForce(f);
  96.                     distance = Vector3.Distance(transform.position, dest.position);
  97.                 }
  98.                 else
  99.                 {
  100.                     dropObject();
  101.                 }
  102.             }
  103.         }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement