The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

So I have a bullet in my space invaders game, and I also have a barrier of a StaticBody2D. I want the bullet when it hits the barrier, to check if the barrier is part of the group Enemy, then disappear, and not break the barrier. I'm getting some weird errors. My most recent error is an Invalid call. Nonexistent function 'isingroup' in base 'KinematicCollision2D'.

Here is my code for the bullet script. Hope it helps :)

extends KinematicBody2D

var speed = 500
var level = 1

func physicsprocess(delta):
var collidedObject = moveandcollide(Vector2(0, -speed * delta))

check if object is in enemy group

if collidedObject:
    if collidedObject.is_in_group("Enemy"):
        #if collidedObject is Enemies
        collidedObject.get_collider().queue_free() #removes what it collided with
        queue_free() # removes itself
        # if enemy group is size 0 then advance level variable by 1
var numEnemies = get_tree().get_nodes_in_group("Enemy").size()
if numEnemies <= 1: 


        get_tree().change_scene("Lvl_" + level + ".tscn")
    # check if object is in enemy group
Godot version 3.4.2
in Engine by (12 points)

1 Answer

0 votes

the problem is the variable "colliided objects". Collided objects is not a node so if you ask for its ''group'' it's going to return an error, try replacing its value. ie.

var collided objects = get_node(that)
by (447 points)

So just create a new variable called CollidedObjects and it should work?

just try this instead, also are youfamiliar with godot or are you new. if the code is showing error make sure there are no space between codes.

extends RigidBody2D

var active = true
var speed = 2000
var level = 1

func _ready():

 #change bullet main node to rigidbody imstead of kinematicbody
func _process(delta):
if active == true:
    linear_velocity.y = -speed
    print("shoul b  moving")

 #add an area node as a child of bullet. then go to inspector, look to the 
 #right you will see a menu which says "nodes", click signals then click the signal which says
#"on_area_body_entered and connect to your bullet script. unti you see a exit like
 #icon beside the function below.

func on_area_body_entered(body):
if body.is_in_group("enemy"):
    print("bullet is working")

let me know if you are still having difficulties :-)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.