0 votes

Video example showing set_translation is working but not for moving back to center:
https://www.youtube.com/watch?v=Qonuh6p5HGo&feature=youtu.be

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.
https://ibb.co/CBcxZtR
screenshot mirror
enter image description here

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?

in Engine by (40 points)
retagged by

1 Answer

0 votes

I found the problem I was using return wrong way in a different script.

by (40 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.