+1 vote

medium and large asteroids collide. I tried to turn off masks and layers for medium asteroids altogether, but they love to come into contact with large asteroids. How to fix this, please tell me.

project https://drive.google.com/file/d/1-rYgteUfpxof8TaATYoqhIqCCYgGctPA/view?usp=sharing

in Engine by (159 points)

I tried to find a fix, but I also cannot see where the incorrect collision mask is being set for the medium asteroid. Very strange!

sorry, I did not understand you. I don't really understand correctly what a layer and a mask are. Is the layer processing the input signal and the mask giving the output signal?

Sort of. Layer = which layers is my collision object in layer 1 could be Player, layer 2 could be asteroids, layer 3 could be pickups. Mask = which layers do I collide with. I do not see why it isn't working for your medium asteroids.

1 Answer

0 votes

Hi,
I managed to get it to work in your code. I had a similar issue once and it took me ages to find out what was wrong or what I think was wrong.

A couple of things first, I'd suggest that you name your collision layers, that way it's easier to see what an object is colliding with.
You have large asteroid on layer 3 and the small and medium asteroids on levels 2 & 3. I'm guessing they all need to be on level 3.
The player mask is set to the same as itself, so I think the mask needs to 3, to collide with the asteroids.

Now the reason I think you are having issues, (this is a bit of a guess) is that you may have copied one of the asteroids to make the medium or big one and something in Godot doesn't like it.
I deleted your middle asteroid and recreated it from scratch and added the script as a file and it works fine.

Here's the code

by (2,063 points)
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.