A huge issue with collision

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
tommyroyall
Prole
Posts: 14
Joined: Fri Nov 02, 2012 12:47 am

A huge issue with collision

Post by tommyroyall »

Hey, so I made a simple game, and I create objects like this:

Code: Select all

  objects.player={}
  objects.player.body=love.physics.newBody(world,SPAWN_X,SPAWN_Y,'dynamic')
  objects.player.shape=love.physics.newCircleShape(25)
  objects.player.fixture=love.physics.newFixture(objects.player.body,objects.player.shape,1)
  objects.player.fixture:setRestitution(0.9)
And I create blocks with a function, called:

Code: Select all

function addBlock(x,y,state)
  blockcount=blockcount+1
  x=x*METER
  y=y*METER
  block_width=METER
  block_height=METER
  objects.block[blockcount]={}
  objects.block[blockcount].body=love.physics.newBody(world,x,y,state)
  objects.block[blockcount].shape=love.physics.newRectangleShape(block_width,block_height)
  objects.block[blockcount].fixture=love.physics.newFixture(objects.block[blockcount].body,objects.block[blockcount].shape,1)
end
Now, there's no issues with the variables as far as I know, but what would cause them to simple not register as colliding? Also, do I need to do anything with the world:setCallbacks()? I used it, seems kind of useless . . .

Also, I didn't supply a .love because this is a fairly large/complex project, and collision just magically died -_-. If you want it though, I will post it.
User avatar
jpnk
Prole
Posts: 8
Joined: Mon Dec 24, 2012 2:12 pm

Re: A huge issue with collision

Post by jpnk »

here's a short checklist for you:
1. check if you use METER correctly
2. check if you use world:setMeter() correctly (if you use it at all)
3. check the dimensions of your world
4. check if you update the world correctly
5. try to visualize all your shapes

you don't need to use world:setCallbacks() just to enable collisions, you use it only to run some code when two bodies collide.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 15 guests