Godot Version
The godot that I’m using currently is 4.5 `
Question
` I’m struggling with making the scene appear when the player presses A or D and then turns to the right 90 degree.
`
The godot that I’m using currently is 4.5 `
` I’m struggling with making the scene appear when the player presses A or D and then turns to the right 90 degree.
Hi,
When a line is highlighted in red, there’s an error below explaining why that is happening. Usually this gives you enough context either to fix the problem yourself, or share it here so that we can have a better understanding at your code.
Could you share your current error?
At a guess, either turn_left(), turn_right() and camera_movement() aren’t defined at all, they take a different number of arguments, or (most likely) they’re in a different file and you need to tell Godot that.
With Godot, symbols refer (mostly) local to file they’re in; turn_left() is expecting a function called turn_left() in the same file. If you want to call a function from somewhere else, you need to prefix the call with a node that’s got that function in it. So, for instance, if you have a global CameraUtils.gd, you’d need to CameraUtils.turn_left(90) outside that file.
Similarly, if you have another node, like (say) the player as var Player, you could call Player.turn_left(90) if the function was in Player.gd.
Note here that I’m conflating file name and class name, but it’s the class name that matters.
Here is the error for my code. So here is my pseudo code for my thinking process. So here is it:
Start
input keybinding (pressing A or Click button)
input keybinding(pressing D or Click button)
camera_movement
turns the player to two directions scenes
if the player press [A] or [Click Left Button]
then the camera moves 90 degrees to the left to a different scene
if the player press [ D] or [Click Right Button]
then the camera moves 90 degrees to the right to a different scene
Stop
I’m so confused on what you saying cause you explain this in simple terms. I have a bad comprehension.
Ah, ok.
var turn_left(90) = camera_left
The var is defining a variable called turn_left, except you have (90) after it, so it’s being called as a function right after being defined as a varaible.
That doesn’t really make sense.
You probably want:
var camera_left = turn_left(90)
That is, declare the variable camera_left, and assign it the value returned by turn_left(90).
oooh so i got i got it backwards? ![]()
Yeah. Assignment (=) assigns the value on the right to the thing on the left. So:
var foo = 5
var bar = calc_value(42)
var baz = "I am a string"
Okay I fixed the variable error but now Line 3, 4, 7, and 10:
var camera_left = turn_left(90)
var camera_right = turn_right(90)
However, it still coming up as 4 error message.
Well have you defined turn_left() and turn_right() functions. Those do not exist by themselves. You need to write the code for them.
You can’t write if statements (or any other statement) outside of functions.
Thank you I would change it
It would not be enough to just “change” it. You need to learn the basics of language syntax before you can start writing any code in that language.