Help with code problems

Godot Version



Hello! I’m making a 3D game and I’m trying to add a feature that, when I press the “E” key, the size on the ground’s Z axis changes to 5 (originally it is 0.1) the code is in one: MeshInstance3D, but it doesn’t it’s working.


func _input(event):
if Input.is_key_pressed(KEY_E) and scale.z == 0.1:
scale.z = 5.0
scale.z = 0.1

What do you mean it’s not working? Did you debug it (or used prints to see what it does)?

Instead of comparing floats directly scale.z == 0.1 try using is_equal_approx(scale.z, 0.1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.