UrbanIndigo / defector-defense

1 stars 0 forks source link

Prevent collision between units/enemies and players #3

Open UrbanIndigo opened 2 years ago

UrbanIndigo commented 2 years ago

@xxOctavianxx Check how the code gets converted from Typescript into Roblox Studio. In ServerScriptService, you'll see there's only one Script and the rest are ModuleScripts. In the filesystem, that's called main.server.ts.

Your next challenge is to prevent collision between units/enemies and players. So we need to create a new collision group using PhysicsService.

Then we need to create a new system in server/systems that assigns this collision group to new players and enemies.

I suggest you use queryChanged on a model, then check if that entity has a Walker or Unit component and change collision group accordingly.

Do the same for the player.

I believe this will be quite difficult for you so let me know if you need help

UrbanIndigo commented 2 years ago

Actually, in unitsHaveModels and walkerSystem, we are checking if there exists a Unit/Walker without a model.

for (const [id, walker] of world.query(Walker).without(ComponentModel)) {
...
}

Here we could assign the collision group to each base part. You can actually see I've already done that for Walkers.

        walkerModel.GetDescendants().forEach((desc) => {
            if (desc.IsA("BasePart")) {
                PhysicsService.SetPartCollisionGroup(desc, "Walkers");
            }
        });