I am fairly new to Unity, and I am making a 2 player dodgeball game. I want the players to be able to pick up the balls that are objects with rigidbodies in the scene. I already have written the C# so that once the player is within a certain distance of the object and a key is pressed, the ball becomes a child of the player, so I need to remove the rigidbody from the ball and reposition the ball relative to the player so that the ball moves with the player. This is my code, where distBallL refers to the distance between the player and the ball (not the issue) and LPickup refers to a ball gameobject in the scene:
if ( distBallL < 2 && Input.GetKeyDown (KeyCode.RightControl)) {
LPickup.transform.parent = transform;
LPickup.GetComponent<Rigidbody>() != enabled;
}
This error is thrown:
error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Any help is appreciated!