Page 1 of 1
Question on Cannon Projectile collision
Posted: Thu Jul 01, 2021 4:46 am
by heyqule
I have "Air" units that based on collision_mask = {}. Rocket can hit them, but cannon-projectile can't. Why is that?
I tried adding data.raw['projectile']['cannon-projectile']['action']['ignore_collision_condition'] = true. That didn't do anything. I thought it would behave like adding it in type="area"
Re: Question on Cannon Projectile collision
Posted: Thu Jul 01, 2021 5:03 pm
by heyqule
I found the issue.
I have to add collision_mask = { 'layer-33' } to air unit and then add the mask to the projectile in hit_collision_mask. eg. data.raw['projectile']['cannon-projectile']['hit_collision_mask'] = { 'train-layer', 'player-layer', 'layer-33'}
Re: Question on Cannon Projectile collision
Posted: Fri Jul 02, 2021 8:25 am
by PFQNiet
Avoid hard-coding collision masks. You don't know what other mods might be using it.
Instead, use this:
Code: Select all
air_unit_layer = require("collision-mask-util").get_first_unused_layer()
Then you can assign collision_mask = {air_unit_layer} and add it to the projectile.
Re: Question on Cannon Projectile collision
Posted: Sat Jul 03, 2021 3:20 pm
by heyqule
oh nice! Thank you for this TIL.
Re: Question on Cannon Projectile collision
Posted: Tue Jul 06, 2021 1:03 pm
by andrei
Hmm, I didn't know this either. Thanks, PFQNiet! I've sent a documentation improvement request for
https://wiki.factorio.com/Types/CollisionMask to mention get_first_unused_layer.