I have some fairly simple code that allows me to grab, move, and let go of objects (in this case, the "LoopCubes" are the only things I want to be able to pick up:
public void grab(object sender, ClickedEventArgs e)
{
if ((objectTouching != null) && objectTouching.CompareTag("LoopCube") == true)
{
objectTouching.gameObject.transform.SetParent(gameObject.transform);
}
}
//Letting go of grip
public void releaseGrab(object sender, ClickedEventArgs e)
{
if (objectTouching != null)
{
objectTouching.gameObject.transform.parent = null;
}
}
This works as intended. However, a problem arises when I want to let go of the cube when the controller/cube are within a box collider (marked as a trigger). I can't let go and the cube becomes 'stuck' to the controller. What am I doing wrong?
Since I can't see your code I'm going to make some assumptions. This is what I'm guessing is happening:
objectTouching
objectTouching
& move aroundobjectTouching
to something else, still having the previous objectTouching grabbed