Collision based on colour

On your BP, you are setting variables My Color on both the Wall and the Sphere. But in your comparison, you’re getting Wall’s Color variable instead of My Color?

Hello there, thank you for reading!

The basic idea is that my character (a sphere) must be the same colour as the wall (a cube) in order to break said wall to be able to progress. I am new to all of this so please be kind haha.

When I press the space bar the character changes colour (Red, Green, Blue). I have walls set up that they randomly chose a colour (I’ll add a photo for anyone who is interested in the Blueprints for it).

The issue that I’m facing is that matching the colours doesn’t destroy the wall. I’ve used an enumeration for the 3 colours.

If the ball is Red or Blue then it wont destroy any wall, no matter the colour. If the ball is Green however then it will destroy every wall, no matter the colour.

It seems to be the 2nd colour that is the only one that can destroy the walls. Colour 1 and 3, so Red and Blue are being ignored somewhere and the second one is just default no matter what.

I’ll add some photos to show you what I mean.

Hope someone can help. Many thanks.

I have a feeling it’s something to do with linking the material colours to the enum. So the Red material I made will need linking to the Red enum in the list?

I’m sorry I don’t quite understand. I’m really new to all of this. My tutor at University told me to create the on component hit blueprint.

The blueprint that changes the colour of the wall doesn’t affect the collision as I’ve deleted it and ran the game again with the same outcome.

The ‘Color’ is linked to the Enum with the 3 colours listed. This is taken from the Wall BP. ‘My Color’ is also linked to the enum but is in the Sphere BP. I’m really new to all of this and it was my tutuor who set this up for me.

Both ‘My color’ and ‘Color’ are Variables that have been selected as enums and then colours (the name of the enumerations).

My ‘color’ is from the character BP and My ‘color’ is from the wall BP

your variables dont seem to be correct. in the wall your setting the variable “MyColor” & in the ball your setting a variable “MyColor”, but also in the ball your asking Does MYcolor =Color. i would guess that your color variable is green by default which would result in the behavior your seeing. so should just need to compare the right variables.

what we are saying is that you are not comparing the right variable. in your wall bp as shown in the picture wall-changes.png you are setting the variable Mycolor, but in the ball bp just after your cast your getting a variable named color. so you have two variables in the wall bp one named color and one named Mycolor, they are not the same thing.what you need to be doing is comparing the mycolor from the wallBP to the MYColor of the ballBP. itd be easier to explain if you named your variables differently.

your setting one variable then getting a different one.

You have 2 conflicting variables:

  1. Color

  2. MyColor

Change all your Color to MyColor and remove Color variables so won’t get confused and made mistakes.

In short, you are setting the colors of the ff.:

Wall: MyColor
Ball: MyColor

But then you are getting the wrong variable from Wall_BP:

Wall: Color (shouldn't it be MyColor and not Color ?)
Ball: MyColor

Would just like to say thank you so so much for all your help. It’s finally working now.

Thank you so much for your help. As if it was something that simple. Hopefully I’ll be able to remember the little things like this in the future

No problem. Even seasoned devs can easily make mistakes like this. And the larger the project the more difficult to find simple bugs like that.