Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Collision detection question - bullets disappear on contact
Post Body

When attempting to detect collision and cause damage to entities, I think that the best approach is to use ICollisionEventsJob where I look at the types of components on each entity while doing combat and add components to destroy them in a different system later. Several questions immediately come to mind but I am not completely sure about the ICollisionEventsJob... most tutorials (very few BTW) seem to emphasize an ITriggerEventsJob but as an old-hat, this seems wrong.

Here are my questions:
1) Is the ICollisionEventsJob best or should I just setup an IJob and look at the CollisionEvents directly. Maybe some other job type or even a different approach altogether.

2) When I add a component to the ECB, can I detect that addition later? For example, does this code even work? If I add the selfDestruct component and then the bullet also happen to strike another entity (the bullets are pretty big), will I be adding a second component to that bullet?

if (selfDestruct.HasComponent(bullet) == false)
{
    entityCommandBuffer.AddComponent(killer, new SelfDestructComponent { deathTime = 0 });// immediately
}

3) What does a good example of a projectile affecting enemies in combat look like? I cannot find a single example online.

4) Is this the proper update setup for a collision detection setup?

[UpdateAfter(typeof(ExportPhysicsWorld))]
[UpdateAfter(typeof(EndFramePhysicsSystem))]
[UpdateInGroup(typeof(PresentationSystemGroup))]
public partial class CollisionSystem : SystemBase

5) Is it possible to setup multiple collision jobs in the same frame for different types? Say one for missiles, another for ships hitting one another, and maby another for explosions hitting the player?

6) If I want to spawn something during a collision like an explosion object, is there a good approach... some way of tracking spawning to do in another System?

Thanks ahead

Author
Account Strength
100%
Account Age
16 years
Verified Email
Yes
Verified Flair
No
Total Karma
22,639
Link Karma
530
Comment Karma
22,051
Profile updated: 2 weeks ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago