![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Nanogines |
It gives me this error. Is there something wrong with my code?
extends KinematicBody2D
const UP = Vector2(0,-1)
var motion = Vector2()
var is_dead = false
var grav = 18
var timer = null
var is_dashing = false
func _physics_process(delta):
if is_dashing == true:
motion.y += grav
motion.x += 1000
if is_dead == false:
motion.y += grav
motion.x = 300
if Input.is_action_pressed("ui_right"):
dash()
if is_on_floor():
if Input.is_action_just_pressed("ui_select"):
motion.y = -400
if Pixel.has_node("pass_through"):
Pixel.set_collision_mask_bit(1,false)
else:
motion.y = -400
move_and_slide(motion,UP)
if get_slide_count():
for i in range(get_slide_count()):
if "Fire" in get_slide_collision(i).collider.name:
dead()
if get_slide_count():
for i in range(get_slide_count()):
if "Flame" in get_slide_collision(i).collider.name:
dead()
func dead():
is_dead = true
$DeathSound.play()
motion = Vector2(0,0)
$Particles2D.emitting = true
$Sprite.play("dead")
$CollisionShape2D.disabled = true
$deadtimer.start()
func _on_Luck_Bits_body_entered(body):
global.luckscore +=1
print(global.luckscore)
func _on_Spring_body_entered(body):
motion.y = -500
func _on_deadtimer_timeout():
get_tree().reload_current_scene()
func _on_dashtimer_timeout():
motion.x = 300
func dash():
is_dashing = true
motion.x = 5000
$dashtimer.start()
If there’s still problems, call print_tree_pretty()
post the output here. Remember to format it with { }
button.
Dlean Jeans | 2019-07-04 10:36
┖╴Pixel
┖╴Pixel
┠╴Sprite
┠╴CollisionShape2D
┠╴Camera2D
┠╴deadtimer
┠╴ParallaxBackground
┃ ┖╴ParallaxLayer
┃ ┖╴Volcano
┠╴Particles2D
┠╴PauseButton
┠╴DeathSound
┠╴pass_through
┃ ┖╴CollisionShape2D
┖╴dashtimer
Nanogines | 2019-07-04 11:06
Why there’s two Pixel
? Maybe it’s the first one that has no timers.
Dlean Jeans | 2019-07-04 12:03
I’m pretty new to this community so I have no idea why there are 2 Pixel? What are the reasons you think for it being here? Also, should I try to find and delete it?
I think the first Pixel might be because I have multiple level scenes in my game so I saved Pixel as its own scene so maybe that’s why there might be 2 pixel
Nanogines | 2019-07-04 12:49