Can any one help me fix this errors?

Godot Version

3





This errors are from my bullet so this is my bullets script

extends Area2D

const min_bullet_speed = 200
const max_bullet_speed = 500
# Speed of the bullet
var BULLET_SPEED = 300

# Maximum angle deviation from vertical (in degrees)
const MAX_ANGLE_DEVIATION = 30

# Called when the node enters the scene tree for the first time.
func _ready():
	# Set the initial position of the bullet (random x at the bottom of the screen)
	randomize()  # Ensure random number generation is initialized
	
	var viewport_width = get_viewport().size.x
	position = Vector2(rand_range(0, viewport_width), get_viewport().size.y)
	
	# Apply a random angle deviation
	rotation = deg2rad(rand_range(-MAX_ANGLE_DEVIATION, MAX_ANGLE_DEVIATION))
	BULLET_SPEED = rand_range(min_bullet_speed, max_bullet_speed)
	connect("area_entered", self, "_on_area_entered")

	

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	# Move the bullet upwards at the given angle
	position.y -= BULLET_SPEED * delta * cos(rotation)
	position.x += BULLET_SPEED * delta * sin(rotation)
	
	# Check if the bullet is out of the screen
	if position.y < -100 or position.x < 0 or position.x > get_viewport().size.x:
		queue_free()  # Destroy the bullet when it goes out of screen
		
func fade_out() -> void:
	var tween = Tween.new()
	add_child(tween)
	tween.interpolate_property(self, "modulate", Color(1, 1, 1, 1), Color(1, 1, 1, 0), 1)
	tween.start()
	print("fade_out")

And need i fix yellow errors ?

There’s no _on_area_entered method, you never implemented that, as the error says

Did you mean to connect it to fade_out?

1 Like

if i connect that to fade out there will be no errors?

func _on_area_entered(area):
# Define what happens when the area is entered
print("Area entered: ", area.name)
i tried to do something like this but dont working

Now you called it _on_Bullet_area_entered, read the error message it tells you what is wrong, just create the correct method or connect it to the correct method

2 Likes

i have connected it to the right method but it gives me this


i add this

connect("area_entered", self, "_on_Bullet_area_entered")

func _on_Bullet_area_entered(area):
	print("Bullet entered area: ", area.name)

Now you’re connecting it twice, not sure where else you connect it, but you connect it twice somewhere which isn’t correct (the error message says what’s wrong)

Just show all of your code

1 Like

Thats my player code

extends KinematicBody2D

var speed = 500
var acceleration = 800
var deceleration = 1000
var velocity = Vector2.ZERO
var axis = Vector2.ZERO
var rotation_speed = 500
var target_rotation = 0.0
var current_rotation = 0.0
var return_speed = 5
var MAX_ROTATION_DEGREE = 30
var PopEffect = preload("res://Scenes/pop.tscn")



func _ready():
	self.connect("area_entered", self, "_on_Area2D_area_entered")
func _physics_process(_delta):

	axis.x = Input.get_action_strength("right")-Input.get_action_strength("left")
	axis.y = Input.get_action_strength("down")-Input.get_action_strength("up")

	axis = axis.normalized() * speed

	velocity = velocity.linear_interpolate(axis, 0.025)

	velocity = move_and_slide(velocity)
	
func _process(delta):
	
	if Input.is_action_pressed("right"):
		target_rotation = deg2rad(MAX_ROTATION_DEGREE)
	elif Input.is_action_pressed("left"):
		target_rotation = deg2rad(-MAX_ROTATION_DEGREE)
	else:
		target_rotation = 0.0
	
	current_rotation = lerp_angle(current_rotation, target_rotation, return_speed * delta)
	rotation = current_rotation
	rotation = clamp(rotation, -PI/8, PI/8)
	

func _on_Area2D_area_entered(area):
	if area.is_in_group("Bullet"):
		die()
		print("bullet")
	if area.is_in_group("Enemy"):
		die()
		print("enemy")
	if area.is_in_group("Border"):
		die()
		print("border")		
	   
func die():
	print("you are dead")
	var pop_effect_instance = PopEffect.instance()
	pop_effect_instance.position = position
	pop_effect_instance.emitting = true
	get_parent().playerDied(pop_effect_instance)
	var game_node = get_node("/root/Game")
	if game_node:
		game_node.stop_timer() 
	queue_free()

i think there is the problem

Then you are also connecting it in the editor with the signals interface, you don’t need to connect it manually in _ready

okay i will delete it

i found it, that was in my bullet ready function connect… i deleted it and then add as you said this :func _on_Bullet_area_entered(area):
print("Bullet entered area: ", area.name).And what about this yellow need i fix this or not i just fear when i export my game it will crash.

That’s just a warning, though you should fix it as it’s an indication you are missing something

But the errors and warnings should tell you what is wrong and what to do about them

1 Like

Okay,thanks for helping !

1 Like

Hey aramkik2007! The yellow errors are pointing out a mismatch between your code and the signal you’re connecting to.

Here’s the fix:

Rename the _on_Bullet_area_entered function to _on_area_entered (lowercase ‘b’). This aligns with the signal name you’re connecting to in _ready().

You don’t necessarily need the fade_out function unless you want the bullet to fade out before disappearing.

That should take care of the errors.

Thanks very much i will try that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.