Jumpy Blocks

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
LemonLake
Prole
Posts: 7
Joined: Thu Jul 25, 2013 7:07 pm

Jumpy Blocks

Post by LemonLake »

I'm having this issue with physics. I have static tiles, and dynamic tiles that start frozen. Whenever I hit the dynamic tiles with the wrecking ball, they move as expected. However, when they're on the ground they start jumping and sliding about, and I can't figure out why. Can anyone help me?

Moving tile codeÄ

Code: Select all

				local newobj={}
				newobj.body = love.physics.newBody(world,i*32-32,j*32-32,"dynamic")
				newobj.shape = love.physics.newRectangleShape(32,32)
				newobj.fixture = love.physics.newFixture(newobj.body, newobj.shape)
				newobj.body:setAwake(false)
				newobj.id = layout[j][i]
				newobj.fixture:setFriction(100)
				newobj.fixture:setDensity(100)
				newobj.body:setMass(0.01)
				newobj.fixture:setCategory(2)
				newobj.fixture:setMask(2)
Static tile codeÄ

Code: Select all

				local newobj={}
				newobj.body = love.physics.newBody(world,i*32-32,j*32-32,"static")
				newobj.shape = love.physics.newRectangleShape(32,32)
				newobj.fixture = love.physics.newFixture(newobj.body, newobj.shape)
				newobj.fixture:setFriction(100)

Wrecking ball codeÄ

Code: Select all

	ball.body = love.physics.newBody(world,player.x,player.y+96,"dynamic")
	ball.shape = love.physics.newCircleShape(15)
	ball.fixture = love.physics.newFixture(ball.body, ball.shape)
	ball.body:setMass(500)
Crane codeÄ

Code: Select all

	player.body = love.physics.newBody(world,player.x,player.y,"kinematic")
	player.shape = love.physics.newRectangleShape(2,2)
	player.fixture = love.physics.newFixture(player.body, player.shape)
	player.fixture:setMask(2)
The crane and ball are connected withÄ

Code: Select all

ropeJoint = love.physics.newRevoluteJoint(player.body, ball.body, 1, 1, 16, 16, 16, false)
Notes:
Up, down: move crane up/down
Left, right: move crame left/right
Music by Eiffel 65
Löve 0.8.0
Compiled with LÖVIDE

Move to the right to find the building to wreck, the movable blocks are reddish

EditÄ For some reason I canöt include the .love file in an attachment, so hereös a dropbox linkÄ
https://dl.dropboxusercontent.com/u/21596039/Game.love
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Jumpy Blocks

Post by Plu »

Can you try changing the Restitution of the fixtures?

https://love2d.org/wiki/Fixture:getRestitution

That's what determines how they bounce, and I don't think you're setting it, so it's just using the default. I'm not sure what kind of value you need and I'm not near my development computer to try, but either something really low or something really high should make them stop jumping around.
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Jumpy Blocks

Post by Eamonn »

I played the game, and couldn't see anything wrong :P Strange. But, the games BGM is awesome!
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
LemonLake
Prole
Posts: 7
Joined: Thu Jul 25, 2013 7:07 pm

Re: Jumpy Blocks

Post by LemonLake »

Unfortunately, setting the restitution was not the issue. I found out that the rectangles are denying the laws of physics and rotating without trigger as if they were wheels. Fixing the rotation solved it, however I want them to be rotatable. Any ideas?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests