prime31 / CharacterController2D

1.07k stars 248 forks source link

Enemies should use CC2D as well? #104

Open aidinzolghadr opened 4 years ago

aidinzolghadr commented 4 years ago

Hi,

Since all objects change the same Physics2D matrix for collisions upon entering Play mode, if one character, like player, set some layers for trigger under CC2D's Trigger Mask, they will be overridden by any other character like enemies having different config for the same thing.

For example currently Player has Layers 1, 2 and 3 set in it's Trigger Mask and Enemy has Layer 4 and when I launch the game and see Physics 2D matrix, I can see Player collision matrix overridden by Enemy's. Hope I've made myself clear. From

Is CC2D is designed with only main character using it in mind or am I missing something here? Any workarounds?

Thanks.

Alriightyman commented 4 years ago

I've used it for a few enemies. And you are right about the Physics2D matrix being changed. You can edit the CC2D in the awake method and comment out or remove the for loop there. However, you will need to manually adjust your Physics2D Matrix.

Setting the layers in the CC2D is just a helpful way of editing the Physics2D Matrix.
Hope this helps in some way.