Hello,
I was going through some code I found in the asset store and I saw a line I didn’t understand.
move = (crouch ? move * crouchSpeed : move);
could somebody give me a quick explanation?
Hello,
I was going through some code I found in the asset store and I saw a line I didn’t understand.
move = (crouch ? move * crouchSpeed : move);
could somebody give me a quick explanation?
It means if crouch is true then the first condition (move * crouchSpeed) will be assigned to move otherwise second condition move will be assigned to move.
It is just if…else in one line. This can be written using if…else as:
if(crouch)
{
move = move * crouchSpeed;
} else {
move = move;
}