#Collisions not raising events.

1 messages · Page 1 of 1 (latest)

safe kiln
#

Yes the option is enabled in both objects, however it isn't raising events on collision.

They are able to collide with each other and the only things that have changed since the last time the code was working is code moving some entities. I reverted the changed yet collision event still weren't being raised.

What am I missing that could potentially affect collision detection.

dry pewter
#

do objects move via physics velocity?

#

if you move them via LocalTransform, the won't collide

novel crow
#

from memory it doesn't work on the rigidbody atm

safe kiln
safe kiln
#

from custom physics authoring

novel crow
#

where / how are you reading events?

safe kiln
# novel crow where / how are you reading events?
[BurstCompile]
public partial struct ProjectileCollisionJob : ICollisionEventsJob
{
    [ReadOnly] public ComponentLookup<ProjectileTag> ProjectileLookup;
    [ReadOnly] public ComponentLookup<ProjectileDeleteTag> ProjectileDeleteLookup;
    [ReadOnly] public ComponentLookup<Enemy> EnemyLookup;

    [NativeDisableParallelForRestriction] public ComponentLookup<EnemyDeleteData> DeleteLookup;

    public EntityCommandBuffer ECB;

    private bool IsEnemy(Entity entity) => EnemyLookup.HasComponent(entity);
    private bool IsProjectile(Entity entity) => ProjectileLookup.HasComponent(entity);
    private bool IsDeleter(Entity entity) => ProjectileDeleteLookup.HasComponent(entity);
    
    public void Execute(CollisionEvent Event)
    {
        UnityEngine.Debug.Log($"Nice");

        if(IsProjectile(Event.EntityA))
        {
            if (IsEnemy(Event.EntityB))
            {
                DeleteLookup.SetComponentEnabled(Event.EntityB, true);
                DeleteLookup.GetRefRWOptional(Event.EntityB).ValueRW.Killed = true;
                ECB.DestroyEntity(Event.EntityA);
                return;
            }
            if (IsDeleter(Event.EntityB))
            {
                ECB.DestroyEntity(Event.EntityA);
                return;
            }       
        }
    }
}
novel crow
#

ok so just classic job

#

and you're scheduling this in fixed update after simulation step right?

safe kiln
#

yup, actually you know what

#

when I changed that other script

#

I changed the scheduling

#

lemme check

#

damn it is

#

that's odd tho, it shouldn't be changing much with collisions