Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 0sait05 |
Video example showing set_translation is working but not for moving back to center:
set_translation
is working for moving the object with pos_up pos_down
input etc (see code) and there’s no error, but when I try to reset the number to place the object back to the center it’s only working for forward and backward but not left or right, up, down. I’m not sure if I’m using “return” properly or not, I’m new to coding.
Screenshot showing i have input in the project.
var s = null
var y = -5
var z = 0
var x = 0
var currentScene = null
#func repeat_me():
func _process(delta):
if Input.is_action_pressed("reset_camera"):
y=-5
return y
if Input.is_action_pressed("reset_camera"):
z=0
return z
if Input.is_action_pressed("reset_camera"):
x=0
return x
if Input.is_action_pressed("reset_camera"):
self.set_translation(Vector3( 0, 0 ,-5))
if Input.is_action_pressed("pos_up"):
y += 0.1
Bitemnode.set_translation(Vector3( x, z ,y))
if Input.is_action_pressed("pos_down"):
y-=0.1
Bitemnode.set_translation(Vector3( x, z ,y))
if Input.is_action_pressed("pos_left"):
x+=0.1
Bitemnode.set_translation(Vector3( x, z ,y))
if Input.is_action_pressed("pos_right"):
x-=0.1
Bitemnode.set_translation(Vector3( x, z ,y))
if Input.is_action_pressed("pos_high"):
z+=0.1
Bitemnode.set_translation(Vector3( x, z ,y))
if Input.is_action_pressed("pos_low"):
z-=0.1
Bitemnode.set_translation(Vector3( x, z ,y))
Even if I change Vector3 to use a variable.
if Input.is_action_pressed("reset_camera"):
x=0
z=0
y=-5
self.set_translation(Vector3( x, z ,y))
or like another example, I still get the same result
if Input.is_action_pressed("reset_camera"):
x=0
z=0
y=-5
Bitemnode.set_translation(Vector3( x, z ,y))
is this a bug?