![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | BlinMaker2077 |
I’am beginer and i was convert my project from version 3.5.1 to version 4.0.0.
Meanwhile fixing some details in code i wsa get previously mentioned error:
nvalid set index ‘x’ (on base: ‘bool’) with value of type ‘int’ .
Once i was said i’am beginer and i’m trying to learn to think like a programmer,
in past i’ve complete the gd script online free course and i’m just beginer who don’t know how to fix that.
If there is somebody who can help me i will grateful to him.
#THERE'S CODE
extends CharacterBody2D
var rychlost = 150
var pohyb = Vector2()
var smer
var bulletSpeed = 500
var bullet = preload("res://Strela.tscn")
#základní pohyb
func _physics_process(delta):
if Input.is_action_pressed("nahoru"):
pohyb.y = - rychlost
elif Input.is_action_pressed("dolu"):
pohyb.y = rychlost
else:
pohyb.x = 0
if Input.is_action_pressed("doleva"):
pohyb.x = - rychlost
elif Input.is_action_pressed("doprava"):
pohyb.x = rychlost
else:
pohyb.y = 0
pohyb = pohyb.normalized()
pohyb = move_and_slide()
look_at(get_global_mouse_position())
if Input.is_action_pressed("střílení"):
strileni()
func strileni():
var bullet_instance = bullet.instance()
bullet_instance.position = get_global_position()
bullet_instance.rotation_degrees = rotation_degrees
bullet_instance.apply_impulse(Vector2(),Vector2(bulletSpeed,0).rotated(rotation))
get_tree().get_root().call_deferred("add_child",bullet_instance)
func vykuchani():
get_tree().reload_current_scene()
func _on_Area2D_body_entered(body):
if "buzerant" in body.name:
vykuchani()