Why is this returning false?

I am checking collision with overlap event. I used to handle this with casting but read it wasn’t a good idea. This returns false when checking if the type is gravity generator with the equal equal component.

Maybe this is some basic c++ stuff I am forgetting.

You would need to compare the types if you really wanted to do this, currently you are comparing an (actual) instance with the default, which indeed will always be false.

But I would advise you to cast. There are good reasons to not cast, but they are not universal and if all you can say about it currently is “I read it wasn’t a good idea” then you should totally ignore what you have read.

If you later read a whole lot more on the subject, and understand well why (in certain situations) it isn’t a good idea and what to do instead, then you will know when to cast and when not to. In the meantime, just cast.

If you find you are getting some unwieldy code doing lots of casts to figure out what something is, that is a good indicator that the time has come to start reading up in more depth on the topic.

1 Like

I will try, unreal is hard. Thank you, happy holidays.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.