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

[Bullet] RigidBody2D bounces when passing on top of two perfectly aligned StaticBody2Ds #28438

Closed
Tracked by #45334
nosklo opened this issue Apr 26, 2019 · 2 comments
Closed
Tracked by #45334

Comments

@nosklo
Copy link

nosklo commented Apr 26, 2019

Godot version:
Happens on 3.1 stable and 3.1.1rc1

OS/device including version:
ubuntu 18.04 / nvidia GTX1070 8GB driver 418.56

Issue description:
When creating two StaticBody2Ds, no matter how well aligned they are, a RigidBody2D passing over them will jump upwards sometimes. I expected the RigidBody2D to just roll over the connection since there is no gap at all, but it jumps instead.

GIF video of the issue
https://media.giphy.com/media/d7SgPewvXmuwsfw8w9/giphy.gif

Steps to reproduce:

Attach the GDScript code below to a Node2D in a new project, and run:

extends Node2D

const STATIC_SIZE = 2000
onready var img = preload('res://icon.png')

func _ready():
	var rb := RigidBody2D.new()
	
	var s = Sprite.new()
	s.texture = img

	rb.add_child(s)

	# Add a circle shaped collision
	var rb_col := CollisionShape2D.new()
	rb_col.shape = CircleShape2D.new()
	rb_col.shape.radius = 50
	rb.add_child(rb_col)

	# Configure to have no friction and no damp
	rb.linear_damp = 0
	rb.physics_material_override = PhysicsMaterial.new()
	rb.physics_material_override.friction = 0
	
	# apply impulse
	rb.apply_impulse(Vector2.ZERO, Vector2(1050, 0))

	# follow with a camera
	var camera := Camera2D.new()
	camera.current = true
	rb.add_child(camera)

	add_child(rb)
	
	# create 10 consecutive StaticBody2D perfectly aligned
	var pos := Vector2(STATIC_SIZE / 2, 200)
	for x in range(0, 10):
		var ground := StaticBody2D.new()
		var ground_col := CollisionShape2D.new()
		ground_col.shape = RectangleShape2D.new()
		ground_col.shape.extents = Vector2(STATIC_SIZE / 2, 100)
		ground.add_child(ground_col)

		# Add a sprite so we can see where the division is
		s = Sprite.new()
		s.position = Vector2(-STATIC_SIZE/2, -50)
		s.texture = img
		ground.add_child(s)
	
		ground.position = pos
		add_child(ground)

		pos.x += STATIC_SIZE

@T0BiD
Copy link

T0BiD commented Aug 23, 2019

Happens for 3d as well

@akien-mga
Copy link
Member

Fixed by #56801.

@akien-mga akien-mga added this to the 3.5 milestone May 19, 2022
@akien-mga akien-mga changed the title RigidBody2D bounces when passing on top of two perfectly aligned StaticBody2Ds [Bullet] RigidBody2D bounces when passing on top of two perfectly aligned StaticBody2Ds May 19, 2022
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

5 participants