About 'Colliders, Collision & Triggers'!

Hey @FernandoLuizRosa

do you know which gameobject triggers the lose collider?

If it’s the baby then try setting the collision detection to ‘continuous’ for the baby’s RigidBody2D component (it solved some weird collision behaviours for me where the ball sometimes glitched inside the paddle)
collision_detection_mode


You could also set the rigidbody's type to kinematic while it is stuck to the paddle. The kinematic mode makes the rigidbody ignore all applied external forces (like gravity).
Just add

GetComponent<RigidBody2D>().isKinematic = true;

to your LockBabyToTroller method (or to the Start method because you have to do that just once) and a

GetComponent<RigidBody2D>().isKinematic = false;

to your LaunchOnMouseClick method (you know where exactly ^^).


Hope this helps

Thank you @Banpa, looks like your first suggestion solved the problem (Collision Detection: Continuous)

Hi,

First of all thanks for a fantastic course, I’m really enjoying it!

In the tiny collision detection script, the parameter “collision” that is declared in () after OnTriggerEnter2D, is greyed out and unknown. So far I’ve been pretty much following step by step, so I’m not sure if and where I missed something. (Probably :slight_smile:)

If anyone knows what’s the issue, I’d be super happy. Thanks for the help!

No issue, its just saying that we have information about the specific collision event (ie. who bumped into me) and we aren’t using that extra information for anything. We don’t need to use it for what we are doing, so its okay to not take advantage of it. You can check this by removing Collider2D collision (ie. just leave the parentheses after OnTriggerEnter2D empty) and it should still work.

Thank you Rick!

Since everything else seems in place, I assumed that this message is connected:

15

I haven’t been able to trigger the Game Over scene. The ball falls through (as it should) and that is it.

Hi,

Your class is called Collision but your filename is saved as LoseCollider, these need to be the same for Untiy to use them correctly. I would suggest renaming your class to LoseCollider.

Then make sure that the script is still attached, run the game again and you should find the code in the OnTriggerEnter2D method is executed correctly.

Hope this helps :slight_smile:

Thank you Rob, it helped. Of course it was a tiny thing and somewhere else than I thought. You’re a life saver :slight_smile:

1 Like

You’re very welcome, happy to help and glad you can move forward again :slight_smile:

Hey Everyone,

The issue I am having:
The ball is pushing my princess sprite.

What I want to occur:
I want my princess’ collider to ignore contact with the ball.

What is actually occurring:
The first contact the ball makes with the Princess is triggering the collider then subsequent contacts are passing through without triggering the collider.

Here is a clip of the gameplay:

it is hard to see the ball passes through the princess again but it does without knocking her again.

Here is my Princess Script

Hi,

Have you considered using the Layer Collision Matrix? As you are already using layers, it may make this fairly straight forward for you.

Incidentally, your can just copy/paste your code into the forum and apply code formatting, it makes it a lot easier to read and for others to subsequently copy/paste back chunks of it when they try to help :slight_smile:


See also;

Hey @Rob

I have not. To be honest I didn’t know it was a thing. I will look into that today to see if I can self correct the problem and let you know how it went.

Thanks for the pointer on the code as well. I thought the screenshot looked neater but being able to copy/paste code is def more viable for code correction.

1 Like

No worries. It was, from memory, covered in the original Laser Defender project I think. Used to prevent enemy projectiles destroying enemies and player projectiles destroying the player - sounds like a similar situation for you.

Hello, i have little problem right here. LoseCollider works for me and it does change the scene, but during the coding i cannot use this shortcut, which shows me examples like here, in the video:

And i cant see this little menu

Can somebody explain what am i doing wrong? The code works at all, i am just wondering why it doesnt work for me in visual studio(just this example, everything before work like in video)

I seem to be having something off with the Lose Collider I keep making and setting it as instructed the script to which I was happy i got correct during the challenge I recopied letter to letter to make sure but no matter what it won’t head on to the Game Over Scene I’m a bit confused whats i’ve done wrong will review video again to see

Here is a look at the set up

Well I have No idea what I did XD I just kept messing with the script changing the names of the scenes and I guess that did it but now it works XD

Just a small bit of feedback on this lesson. Your slide displaying the collision/trigger matrix is not very color-blind friendly. The yellow and green font look nearly identical to me.

Cheers!

1 Like

Let’s give @Rick_Davidson a shout out and see if there’s anything he can do…

Thanks for pointing this out Ryan, I’ll keep my eye out for this moving forward. Hopefully the data is clear enough with the triggers being different to the collisions, even if the colour isn’t helping to reinforce this distinction.

1 Like

Yeah, I had no problem understanding the chart. It’s really not that big of an issue; just figured I’d point it out for the future.

Cheers!

1 Like

I saw it myself yesterday, quite perchance, and would agree. I am also colour blind (reds/greens) and I couldn’t easily tell the difference between the two zones. Perhaps a high contrast black text on white boxes and white text on black boxes would help with this type of slide, it would also emphasise (in this case) the diagonal separation of the items also. Just a thought @Rick_Davidson

1 Like

Privacy & Terms