Invalid operands "bool" and "int" in operator "|"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheMoose
extends KinematicBody2D

export (int) var speed = 200

var velocity = Vector2()
var Bullet = load("res://Bullet.tscn")
var shoot_timer = 0

func get_input():
	velocity = Vector2()
	if Input.is_action_pressed('ui_right'):
		velocity.x += 1
	if Input.is_action_pressed('ui_left'):
		velocity.x -= 1
	if Input.is_action_pressed('ui_down'):
		velocity.y += 1
	if Input.is_action_pressed('ui_up'):
		velocity.y -= 2
	velocity = velocity * speed

func shoot():
	if Input.is_action_just_pressed("ui_accept") & shoot_timer == 0:
		var bullet = Bullet.instance()
		get_parent().add_child(bullet)
		bullet.position = Vector2($".".position.x, $".".position.y - 40)
		shoot_timer = 50

func _physics_process(delta):
	get_input()
	shoot()
	move_and_slide(velocity)
	shoot_timer = shoot_timer - 1

FYI, when editing your post, there is a button that looks like this: {}

This button will format your code so that it is readable.

kidscancode | 2018-06-06 16:24

:bust_in_silhouette: Reply From: kidscancode

You didn’t say what line the error was on, so I’m going to guess it was this one:

if Input.is_action_just_pressed("ui_accept") & shoot_timer == 0:

For an “and” comparison use the and or && operator.
See GDScript reference — Godot Engine (latest) documentation in English

Thank you so much

TheMoose | 2018-06-06 19:05