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

Improved kinematic body, Now can move rigid body #16757

Merged
merged 1 commit into from
Feb 20, 2018

Conversation

AndreaCatania
Copy link
Contributor

Now kinematic body can interact with rigid body.

Fixes #16329
Fixes #13148

@AndreaCatania
Copy link
Contributor Author

Now it's possible to push even with 2D kin body

@akien-mga akien-mga merged commit 497a4e9 into godotengine:master Feb 20, 2018
@akien-mga
Copy link
Member

Thanks, great feature :)

@AndreaCatania AndreaCatania deleted the kinpush branch February 20, 2018 14:50
@MarianoGnu
Copy link
Contributor

Amazing!

@@ -362,12 +363,12 @@ struct _RigidBody2DInOut {
int local_shape;
};

bool RigidBody2D::_test_motion(const Vector2 &p_motion, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {
bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to update the RigidBody.test_motion() bindings here https://github.com/godotengine/godot/blob/master/scene/2d/physics_body_2d.cpp#L890 to add the infinite_inertia parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks you... I forgot it because yesterday I got some issue with bindings so I removed it from all bindings to test it and apparently I forgot to re-add it.

Thanks you

@David-Ochoa
Copy link

I'm having problems waking up rigid bodies with Kinematic bodies, I don't know if it is the same issue, I'm adding a little project to show the problem.
PhysicsTest.zip

@AndreaCatania
Copy link
Contributor Author

@David-Ochoa you have to use only one move_and_slide here the correct player physics process:

func _physics_process(delta):
	var vel = Vector3()
	if (Input.is_action_pressed("ui_up")):
		vel += (Vector3(0,0,-velocity))
	if (Input.is_action_pressed("ui_down")):
		vel += (Vector3(0,0,velocity))
	if (Input.is_action_pressed("ui_left")):
		vel += (Vector3(-velocity,0,0))
	if (Input.is_action_pressed("ui_right")):
		vel += (Vector3(velocity,0,0))
		
	vel += Vector3(0,-10,0)
	move_and_slide(vel, Vector3(0,1,0))

@David-Ochoa
Copy link

@AndreaCatania : I made the changes but still it is not working, one ball hits the "player" before hiting ground, that one can wake up other rigid bodies but player can't, here is a video:
Kinematic vs Rigid body test

@AndreaCatania
Copy link
Contributor Author

@David-Ochoa Fixed: #18138, Can you please confirm it?

@David-Ochoa
Copy link

David-Ochoa commented Apr 12, 2018

@AndreaCatania Yes, it is working now, thanks and great job.

@ghost
Copy link

ghost commented Apr 24, 2018

Just a heads-up. The engine parses the old move_and_slide's 3rd parameter (float) as bool without errors, and the character won't move as expected.

For example:

move_and_slide(vel, Vector3(0,1,0),       0.05,         4,   MAX_SLOPE) # 3.0.2
# is parsed as...
move_and_slide(vel, Vector3(0,1,0), true,    4, MAX_SLOPE, deg2rad(45)) # Master
# which should be...
move_and_slide(vel, Vector3(0,1,0), true, 0.05,         4,   MAX_SLOPE)

Should be added to the list of known incompatibilities for the next version.

@nazgum
Copy link

nazgum commented Jan 12, 2019

Ok so how can we make KinematicBody2D not push RigidBody2D's around, if we don't want that behavior? So it works like in 3.0?

I have a top down game where enemies/crates are RigidBody2D, and after upgrading to beta 3.1, the player can push enemies/crates around now. Changing Mass, Friction and Linear Damp seem to not help in stopping this new behavior.

Update: for anyone else who runs into this, I found out it can be controlled with the infinite_inertia option which is set in move_and_slide; true means you push rigidbodies, and false means you don't =)

@MarianoGnu
Copy link
Contributor

If you use move_and_collide instead of move_and_slide you wont push bodies

@michaeltintiuc
Copy link

Does this also mean that rigid bodies will not move a stationary kinematic body if infinite inertia is on? Also how would you control the force with which kinematic bodies move rigids around, in 3.0 properties like mass and weight are not taken into account

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

Successfully merging this pull request may close these issues.

None yet

7 participants