Navigation Menu

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

Add possibility to retrieve info on last collided entities #270

Closed

Conversation

CalvinMT
Copy link
Contributor

@CalvinMT CalvinMT commented Jun 4, 2019

Saves the first collided entity while a move check.
The saved entity can then be accessed by the moving entity so it can get details on the entity it just collided with.

Saves the first collided entity while a move check.
The saved entity can then be accessed by the moving entity so it can get details on the entity it just collided with.
@steffen-wilke steffen-wilke self-requested a review June 4, 2019 11:44
@CalvinMT
Copy link
Contributor Author

CalvinMT commented Jun 6, 2019

I chose to change the wording because I couldn't find a way to efficiently reset both entity and otherEntity.
The getLastCollidedEntity has now, in my oppinion, more sense because it allows the user to get the last encounted entity.

@CalvinMT CalvinMT changed the title Add possibility to retrieve info on a collided entity Add possibility to retrieve info on the last collided entity Jun 6, 2019
@steffen-wilke
Copy link
Contributor

Thank you for the PR!

For your information: Before reviewing this request: I've planned to introduce an event-based solution for this which would provide you with all the information about a collision that occurred. Also: It's possible that a single move collides with multiple entities within a single tick. I'll investigate the possibilities here next week when im on holiday :) Also there's a TODO in our PhysicsEngine about that topic which I recently added.

@CalvinMT
Copy link
Contributor Author

CalvinMT commented Jun 6, 2019

I've planned to introduce an event-based solution for this which would provide you with all the information about a collision that occurred.

Events could be a good solution. To be honest, I was too lazy to take that road.

It's possible that a single move collides with multiple entities within a single tick.

I think it is possible, in the way I've done it, to take count of all entities colliding within a single tick. The only problem being that all entities which canCollide() will have to be checked for collision.
I'll update this branch with a solution for the above by next week.

Also there's a TODO in our PhysicsEngine about that topic which I recently added.

I saw, but did not understand the last line:
// We need to aggregate the delta X and delta Y for all collision boxes that the entity is colliding with.

It is now possible to retrieve information of all encountered entities after calling the move() method.
Changing back to previous code style.
@CalvinMT CalvinMT changed the title Add possibility to retrieve info on the last collided entity Add possibility to retrieve info on last collided entities Jun 8, 2019
It (still) wasn't possible to retrieve information from an encountered entity after the collision took place because the list was cleared on the next move() call.
This is now fixed.
@steffen-wilke steffen-wilke self-assigned this Jun 10, 2019
@CalvinMT
Copy link
Contributor Author

CalvinMT commented Jul 2, 2019

Hi @steffen-wilke !
Any news for that PR or same kind of feature?

@steffen-wilke
Copy link
Contributor

@CalvinMT I was playing around with an implementation at the weekend. There is no state to share just yet but I think I'd like to go with the event-based approach because it seems like a cleaner solution. Your recent change from #281 is also a nice addition to this topic. I'll see what I can do this week.

steffen-wilke pushed a commit that referenced this pull request Dec 29, 2019
This event gets called whenever an actual collision had to be resolved during the movement of an entity. It can be subscribed to by registering an event listener via ICollisionEntity.addCollisionListener.

PR #270
@steffen-wilke
Copy link
Contributor

I've implemented a collision event on the ICollisionEntity with commit d14fa49 which covers the functionality that was discussed in this PR.

@CalvinMT Thanks for providing your solution and triggering the discussion about that topic 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants