I am trying to create a simple asteroids clone. I’m using boulders instead of asteroids and in my boulder scene I have created a function called split boulder. Once the bullet (area2d) hits (enters) the boulder(rigidbody2d) it calls the function which then is supposed to create two smaller boulders and erase the original boulder. I seem to be having issues with my new instatiated boulders not having the same functions or variables as the original scene and I don’t understand why. The two new boulders are created, but their scale does not change and then if I shoot them again the game crashes. The error I receive is *invalid call. nonexistent function in base rigidbody2d. I’ve never had an issue with instantiated scenese not having functions in the previous games I made so I’m not sure what I’m doing wrong. I’ve attached an image of my boulder script. the function from my bullet that interacts with the bullet is this.
Sorry I probably could have formatted my message better. That part of the code is in my bullet (area2d) node and is attached to the on body entered signal. So when the bullet it hits the boulder(rigidbody2d) it calls the function split_boulder() from the boulder and destroys itself. The actual boulder code is in the image that is attached. The print call was for debugging an earlier issue.
Before you replied I ended up getting rid of the preload and changed my var a and b to load(“res://Scenes/boulder.tscn”).instantiate() so I think you were on the right track. I then created variables for the sprite2d and collision shape and changed the scale of those instead of the rigidbody2d. Everything is now working as I originally intended. Thank you for your help it was driving me crazy. I should have looked at some of the errors in the debugger. They gave me warnings for those two things.