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 "on_collision" callbacks for entities #5458

Closed
MarkuBu opened this issue Mar 26, 2017 · 12 comments
Closed

add "on_collision" callbacks for entities #5458

MarkuBu opened this issue Mar 26, 2017 · 12 comments
Labels
Duplicate Feature request Issues that request the addition or enhancement of a feature @ Server / Client / Env.

Comments

@MarkuBu
Copy link
Contributor

MarkuBu commented Mar 26, 2017

I propose to add two functions for entities

  • on_entity_collision()
    If two entities collide the callback from both entities is called with a reference to the other entity

  • on_node_collision()
    this callback is called every time an entity hits a new node. So if an entity doesn't moves over the surface this callback wouldn't be called. If an entity enters a new node or hits a node in front the callback is called with the pos of the node

I think this would be very useful for mods like bows and arrows or for mobs

@paramat paramat added Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature @ Server / Client / Env. labels Mar 26, 2017
@Desour
Copy link
Member

Desour commented Sep 8, 2017

It would be very useful if it can be done without much lag.

@rubenwardy
Copy link
Member

this would be a nice feature, especially if done in a way that players can also use it. A few mods, eg: mesecons, currently use on_globalstep to detect if a player is stepping on a node.

@raymoo
Copy link
Contributor

raymoo commented Sep 8, 2017

@rubenwardy
I think the overhead of using on_globalstep for that purpose is not very high, provided all "stepping" handlers are dispatched to by a single globalstep (ideally a central mod that allows registering these handlers, but one globalstep per mod that wants the behavior would be ok in my opinion).

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Sep 9, 2017

This is very important for anything dynamic. There is an almost infinite number of use cases for this, some examples were posted before.

@SmallJoker
Copy link
Member

Related issues:

@paramat paramat added Feature request Issues that request the addition or enhancement of a feature and removed Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature labels Sep 16, 2017
@xunto
Copy link
Contributor

xunto commented Nov 6, 2017

We really need this callback. I looked through some "archery" mods and all of them check collision using on_step callback, some of them even calculate collisions with collisions boxes, while obviously this work already done in core (physical = true and collide_with_objects = true). I tried tracking speed changes with physical = true to notice collisions, it worked but looked hacky.

@paramat
Copy link
Contributor

paramat commented Nov 8, 2017

@SmallJoker is working on a bows mod that uses raycast to detect objects on the shoot line.

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Nov 8, 2017

Well, that might work, but I think that doesn't help for many other use cases. Arrows are small objects. A raycast may work. How many rays do you want to cast if you have bigger objects?

@paramat
Copy link
Contributor

paramat commented Nov 8, 2017

Yes, i was just replying to xunto's usecase.

@xunto
Copy link
Contributor

xunto commented Nov 8, 2017

@paramat Hmm, maybe I should try it. Even though I've already written collision check in lua for my spellcasting mod.

@SmallJoker
Copy link
Member

@paramat Please note that raycast does not handle collisions (walkable and collision box values) and is more suitable to get a pointed thing with a direction and position given. For bigger objects, each collision box edge would have to be cast, which seems to be more hacky than simply using the physical attribute in combination with the velocity it had before colliding.

@rubenwardy
Copy link
Member

duplicate of #3918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Feature request Issues that request the addition or enhancement of a feature @ Server / Client / Env.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants