I disabled collision between the player and the pickable objects to prevent jitteriness whenever the picked-up object is colliding with the player while moving.
public void BreakConnection()
{
pickupRB.constraints = RigidbodyConstraints.None;
currentlyPickedUpObject = null;
lookObject = null;
physicsObject.pickedUp = false;
currentDist = 0;
Physics.IgnoreLayerCollision(layer1, layer2, false);
}
public void PickUpObject()
{
Physics.IgnoreLayerCollision(layer1, layer2, true);
physicsObject = lookObject.GetComponentInChildren<PhysicsObjects>();
currentlyPickedUpObject = lookObject;
// currPicked = true;
pickupRB = currentlyPickedUpObject.GetComponent<Rigidbody>();
pickupRB.constraints = RigidbodyConstraints.FreezeRotation;
physicsObject.playerInteractions = this;
}
I tried this Physics.IgnoreLayerCollision(layer1, layer2, true); when the object is picked up and Physics.IgnoreLayerCollision(layer1, layer2, false); when it is realised.
However, it is causing unwanted behaviour with other pickable objects. Is there a way to ONLY disable collision between the currentlyPickedUpObject and the player? not all the pickable objects?
I need currentlyPickedUpObject to collide with all other objects except the player. please help.