I found the problem!!!
E 0:00:28:817 area_2d.gd:6 @ _on_area_entered(): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead.
I have no idea what that means
I found the problem!!!
E 0:00:28:817 area_2d.gd:6 @ _on_area_entered(): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead.
I have no idea what that means
Okay, I tried it again, and I got two errors this time while walking into the problem area
E 0:00:02:020 playerroom_entrance.gd:5 @ _on_area_entered(): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead.
E 0:00:02:023 playerroom_entrance.gd:7 @ _on_area_entered(): Cannot get path of node as it is not in a scene tree.
Also a problem: henever i try to add call_deferred(), the entrance simply doesnt work
The second error looks like it is happening because it has already been removed from the scene tree.
How do you use call deferred and what do you call with it?
Do you want to switch between scenes or just change position within the same scene?
If you would describe where you are at now, what works and doesn’t work, i could give a better answer. This thread is too long for me to want to read it in its entirety.
so ive tried this:
get_tree().change_scene_to_packed.call_deferred("res://scenes/rooms/playerroom_room.tscn")
and this:
get_tree().change_scene_to_file.call_deferred("res://scenes/rooms/playerroom_room.tscn")
This second one allows the player to enter but doesnt fix the huge problem im having. If you give me a few moments i can definitely summerize
So when I was playtesting my game, I came out of the player’s room, as you do lol. But with this room and a few others, I have the problem of if you go down from when you get out of the area of the door (or, in the case of one of my others rooms, if you just go into a certain area), it will teleport you back into the room you just exited (with the other room, theres a problem of it teleporting you to a completely different room, although that may not be related to this problem). Although, ive looked everywhere, and nothing is overlapping with the player area at all, let alone something that would make it teleport into those rooms. (If you scroll up a bit, you’ll see a drawing I made about my problem). I tried area.get_path, and everytime I enter the actual door, it prints the path to the player’s area its colliding with as it should, which has a unique name. But, whenever I walk into the problem area, it prints 'root → hallway → player → control → Area2D. My player, not in a single scene, has either a control or area2d node attached to it.
OK! And this is just for a few of the doors, not all doors?
What if your delete the broken doors and replaces them with duplicates (not copies) of working doors or new instances of the door scene? Perhaps you have accidentally changed some setting or line of code here or there.
Are the doors all of the same kind? Perhaps some door class with an export for which scene to switch to when entered? It sounds like you have several different types of doors. Does the ones that cause issues have anything in common that the other doors don’t?
If not, I would maybe give it a day or two if you feel like it, if no ideas pop up, move on. At some point i think it would be better to give up and try to make a new door class. It is not something that typically would take a lot of time. Especially now that you have dug around with these problems for some time. If there are weird issues like control nodes suddenly appearing in your player scene when they shouldn’t, areas signaling entered even when not entered, new doors breaking when old ones are fixed etc etc - i think the amount of time you will spend debugging will be greater than just creating a new door script.
I would first start with just deleting either the broken doors or all doors and replace them with new instances of the door scene. No copies but duplicates are ok.
Okay, I’ll try that!
To answer your question though, when I was making the doors, I copy and pasted the same shape of the area 2d and the collision shape, but none share the same script.
I found out what it was lol, apparently I was being stupid.
There was a rouge area attached to my main menu screen, and thats whats triggering everything, i didnt realize I added that. Im so sorry for wasting all of your times!!
Thank you for helping me realize my problem lol :,D
Ok! I just want to add something quickly, even though you’ve solved the problem already! It can be very helpful to create a class when you want to reuse the same thing but still be able to tweak it slightly.
If you create a door class for example, you wouldn’t have to copy paste the code and spread it out into several scripts. If you fix some bug once or make an improvement (for example adding sound effects) once, the improvement will happen to all the doors, and if you need to look for a bug, there is only one place to look for it in. And if you want to make some door behave a bit differently, just extend your door class and change it the way you want. Then you will still have whatever you don’t change exactly the way it is in the door class, but perhaps sound effects will be different or this specific type of door will deal damage to any player that walks through.
To create a class, just create an empty script down in your file system in the bottom left, copy paste your door script into it, add class_name Door (or whatever you want to call it) as the top line. After that, you can just add a script that says extends Door to any door you create and it will have all the code from that script in your file system. I think it will make things a lot easier for you than having a lot of separate scripts on the doors. And just things in general. Instead of coding an inventory item 20 or 90 times, just code it once and extend it to make small variations. Ok this one removes poison status, this one heals you, this one gives you currency - but otherwise they just behave the same as you decided in the InventoryItem class.
oh my gosh thank you!!! Ill try that ^^