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

test_motion doesn't return collision with other RigidBody2D #43202

Open
Tracked by #45334
bitbutter opened this issue Oct 30, 2020 · 1 comment
Open
Tracked by #45334

test_motion doesn't return collision with other RigidBody2D #43202

bitbutter opened this issue Oct 30, 2020 · 1 comment

Comments

@bitbutter
Copy link

bitbutter commented Oct 30, 2020

Godot version: 3.2.2

OS/device including version:
iMac
Operating system: Darwin-19.3.0-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 580 OpenGL Engine ATI Technologies Inc. 4.1 ATI-3.5.5

Issue description:

My test scene has two RididBody2Ds. The first has a script that uses test_motion to check for collisions to the right of itself. A second RididBody2D is over the the right. Behind that is a StaticBody2D wall. All physics nodes have their collision layer and masks at the default settings.

The code on the left-hand RigidBody2D uses test_motion to check for collisions to its right. I have a collision_marker sprite, a red circle, to visualise where the collision from the test_motion call is reported.

I was expecting the test_motion call to return a collision with the other RigidBody2D, but it seems to be ignoring it (reporting a collision with the wall beyond it instead, a StaticBody2D)

This is the code on the left-hand RigidBody2D

extends RigidBody2D

func _process(delta):
	var result = Physics2DTestMotionResult.new()
	var hit = self.test_motion(Vector2(30000,0),true,0.08, result)
	if hit:
		$collision_marker.set_global_position(result.get_collision_point())

screenshot

But if i alter the right-hand rigid body to static mode, the collision circle appears where i expected it

screenshot2

Steps to reproduce:
Open reproduction project, run the scene. The marker circle stops at the right-hand static body 'wall' (not the Rigid Body in front of it)

Minimal reproduction project:

test_motion_bug.zip

@bitbutter
Copy link
Author

Seems not to be a bug, but a documentation issue.

Changing the infinite inertia setting to false gives the expected result.
var hit = self.test_motion(Vector2(30000,0),false,0.08, result)

Elsewhere in the docs infinite inertia is described like this

If infinite_inertia is true, body will be able to push RigidBody2D nodes, but it won't also detect any collisions with them. If false, it will interact with RigidBody2D nodes like with StaticBody2D.

It'd be good to include this passage in the description of all methods that have the infinite_inertia parameter (the test_motion description doesn't include it currently). https://docs.godotengine.org/uk/latest/classes/class_rigidbody2d.html?highlight=test_motion#class-rigidbody2d-method-test-motion

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

No branches or pull requests

3 participants