Hi im new to unity. i would like to ask… how can i make my object(Ring) move? that every time you tap the button(button A) the object(ring) will go upward and if i stop tapping the object(ring) will goes down. The Game is underwater. The goal of the game is to shoot the object(ring) into the pole. please i need your help. Thank you so much. ASAp
if(Input.GetKey(upKey)){
rigidbody2D.velocity.y = moveSpeed;
}
else if(Input.GetKey(downKey)){
rigidbody2D.velocity.y = moveSpeed * -1;
}
else if(Input.GetKey(leftKey)){
rigidbody2D.velocity.x = moveSpeed * -1;
}
else if(Input.GetKey(rightKey)){
rigidbody2D.velocity.x = moveSpeed;
}
else {
rigidbody2D.velocity.y = 0;
rigidbody2D.velocity.x = 0;
}
You’re going to need a variable
like var moveSpeed: float = 10;