Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | somebody1134 |
I came across a really strange quirk today while coding a “shield” health system:
var Armor = 50.0
func _ready():
damage(50.0)
func damage(amount):
Armor -= amount * 2 / 3
This sets armor to the expected value (~16.66), however:
func damage(amount):
Armor -= amount * (2 / 3)
This does not subtract anything from the armor. Armor remains at 50.
I prefer to have my fractions formatted in parentheses for more readable code. Why does this make a difference?