Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling collision with robot-wall #10

Open
gabrielsr opened this issue Sep 5, 2020 · 5 comments
Open

Handling collision with robot-wall #10

gabrielsr opened this issue Sep 5, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@gabrielsr
Copy link
Collaborator

It is already implemented a detection collision system but the collision is not handled. This means that as is a robot can pass through a wall or another robot.

We should implement a system that makes the robot bounce back when it collides with a wall.

@gabrielsr gabrielsr changed the title Handling collision with a wall Handling collision with robot-wall Sep 5, 2020
@Gguidini Gguidini added this to To do in Development Process Sep 10, 2020
@Gguidini Gguidini moved this from To do to In progress in Development Process Sep 10, 2020
@Gguidini Gguidini self-assigned this Sep 10, 2020
@Gguidini Gguidini added the enhancement New feature or request label Sep 10, 2020
@Gguidini
Copy link
Collaborator

There are two different approaches we can do right now:

First is to modify the collidable component to accept a callback function. This function will take 2 args: the ID of the entity (self) and the ID of the entity I'm colliding to.

A different option would be to have the Collidable component accept a string, which would be the event tag for a reactive system. Upon colliding, the entity would fire up that event (e.g. add the event to the EventStore) to be picked up by the matching system.

Of course, in the future we might have both, but to begin with something, what do you guys think?
I prefer option 1 for now. It's simpler and faster to implement.

@gabrielsr
Copy link
Collaborator Author

I preferer events =)
@Gguidini could you elaborate more about the 'event tag'? Wouldn't a generic event collision (entity A, entity B) suffice?

@Gguidini
Copy link
Collaborator

If we add custom event tags then we can have custom collision handling systems. Adding the tags would allow for each system to retrieve from the EventStore only the events directed at them. It would have the form (tag, entity A, entity B).

Not every object reacts the same way when colliding, so I think it makes sense to have different systems for that.

@Gguidini Gguidini moved this from In progress to Done in Development Process Sep 13, 2020
@Gguidini
Copy link
Collaborator

Robots now stop when they collide to a Wall (changes).

I will NOT be closing this issue though, because that is a very crude implementation.
Particularly when colliding round shapes diagonally it needs much improvement.

@gabrielsr
Copy link
Collaborator Author

Not every object reacts the same way when colliding, so I think it makes sense to have different systems for that.

It looks like a collision handling logic for me, not collision detection logic. In that case I would make a single system handling collisions calling different sub-behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants