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

Collision info should contain references to collided objects. #9787

Closed
Hume2 opened this issue May 1, 2020 · 1 comment · Fixed by #9768
Closed

Collision info should contain references to collided objects. #9787

Hume2 opened this issue May 1, 2020 · 1 comment · Fixed by #9768
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API @ Server / Client / Env.

Comments

@Hume2
Copy link

Hume2 commented May 1, 2020

Problem

Recently, the on_step function has a new argument, the collision info. It's nice but one serious thing is missing. When the object collides with another object, it only receives that it has collided with A OBJECT but it doesn't get any information about what kind of object it is. It is quite common in games that colliding with different objects has different results. For example, when an arrow hits an animal, it should damage only the hit animal. If you do it vice-versa, the animal has to know somehow that it was hit by an arrow and not by a different object. Currently, there's no way to do this in any of those two ways.

Solutions

Add a reference to the collided object into the collision info.

Alternatives

I don't see any alternative solution here.

Additional context

SuperTux :D https://github.com/SuperTux/supertux/blob/master/src/collision/collision_listener.hpp

EDIT by SmallJoker: Fix link.

@Hume2 Hume2 added the Feature request Issues that request the addition or enhancement of a feature label May 1, 2020
sfan5 added a commit to sfan5/minetest that referenced this issue May 1, 2020
@sorcerykid
Copy link
Contributor

This is resolved by #9717 which includes a table of ObjectRefs in the move result.

You can see how this field is used in my Mobs Lite mod:

https://bitbucket.org/sorcerykid/mobs/src/master/init.lua#lines-1305

if #move_result.touched_objects > 0 and self.on_impact then
	for i, v in ipairs( move_result.touched_objects ) do
		self:on_impact( pos, old_vel, v )
	end
end

sfan5 added a commit to sfan5/minetest that referenced this issue May 5, 2020
sfan5 added a commit that referenced this issue May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API @ Server / Client / Env.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants