Godot Engine

Godot Engine

t3di Aug 3, 2020 @ 12:07pm
Expected else after ternary if...
So I have this piece of code:

extends KinematicBody onready var player = get_node(".") var direction var player_rotation func _physics_process(delta): direction = 0 player_rotation = player.get_rotation_degrees() if Input.is_action_pressed("ui_up"): move_and_slide(Vector3(0,0,10).rotated(Vector3(0,1,0), deg2rad(direction)) #if Input.is_action_pressed("ui_down"): #move_and_slide(Vector3(0,0,-10)) #line where the error appears: if Input.is_action_pressed("ui_left"): player.set_rotation_degrees(player_rotation + Vector3(0,10,0)) direction += 1 #move_and_slide(Vector3(10,0,0)) if Input.is_action_pressed("ui_right"): player.set_rotation_degrees(player_rotation - Vector3(0,10,0)) direction -= 1 #move_and_slide(Vector3(-10,0,0))

error(17,39): Expected else after ternary if.

Why?
Originally posted by DaNaXi:
You forgot to close function with an third )

if Input.is_action_pressed("ui_up"): this line-> move_and_slide(Vector3(0,0,10).rotated(Vector3(0,1,0), deg2rad(direction)))
< >
Showing 1-4 of 4 comments
The author of this thread has indicated that this post answers the original topic.
DaNaXi Aug 3, 2020 @ 12:37pm 
You forgot to close function with an third )

if Input.is_action_pressed("ui_up"): this line-> move_and_slide(Vector3(0,0,10).rotated(Vector3(0,1,0), deg2rad(direction)))
Matt [Linux] Aug 3, 2020 @ 1:05pm 
those pesky brackets
t3di Aug 3, 2020 @ 1:40pm 
Originally posted by PentaiHorn Linux:
those pesky brackets

They always got me, I'm starting to note them like:
speed=Vector3(0,0,10) normalized_y = Vector3(0,1,0)

So I can have less brackets in a sentence, it helps a lot and I recommend it to anyone seeing this post.

Btw it makes easier for later modifications and even ading an "export" at the begining of the variable will help you with not even touching the script for twicks.

export var speed = Vector3(0,0,10)


I've made this comment so somebody can actually learn from this post, not only closing the brackets... And I'm ashamed of not closing them consistently


Thank you, for the answers to my noobie question!
t3di Aug 5, 2020 @ 8:41am 
Originally posted by fauxtronic:
The IDE will hopefully include a feature like this[marketplace.visualstudio.com] one day. ;)
Woah... I need this
< >
Showing 1-4 of 4 comments
Per page: 1530 50

Date Posted: Aug 3, 2020 @ 12:07pm
Posts: 4