slow bullets with physics simulation
Posted: Mon Jan 13, 2014 1:00 pm
Hi everyone!
I tried using love.physics to shoot bullets on a top-down map with several obstacles.
My first thought was that using love.physics might come in handy at some point and I wanted to use it anyway, so I gave it a shot.
But now I think that a very fast, very small bullet might not be suitible for love.physics/box2d.
Creating, fireing and colliding the bullets really was not much of a problem and I was happy with my choice. But I can't get the bullets to any "bullet like" high speed at all.
bullet creation:
I obviously have not too much of a clue about box2d best-practices. And I am not offended if you tell me that the whole idea was pretty stupid.
And I want to say that I have searched the internet/this forum without helping results before posting here, but I am sure you hear that a lot ...
I could supply a .love file, but the code looks horrible as it just grew over the past few hours from a small idea.
Any help in any direction would be much appreciated!
rellig
I tried using love.physics to shoot bullets on a top-down map with several obstacles.
My first thought was that using love.physics might come in handy at some point and I wanted to use it anyway, so I gave it a shot.
But now I think that a very fast, very small bullet might not be suitible for love.physics/box2d.
Creating, fireing and colliding the bullets really was not much of a problem and I was happy with my choice. But I can't get the bullets to any "bullet like" high speed at all.
bullet creation:
Code: Select all
projectile = {};
projectile.body = love.physics.newBody(World, player.pos.x, player.pos.y, "dynamic");
projectile.shape = love.physics.newCircleShape(1);
projectile.fixture = love.physics.newFixture(projectile.body, projectile.shape);
projectile.body:setBullet(true);
local speed = 10000;
local x = speed * math.cos(player.rot);
local y = speed * math.sin(player.rot);
projectile.body:applyLinearImpulse(x, y);
And I want to say that I have searched the internet/this forum without helping results before posting here, but I am sure you hear that a lot ...
I could supply a .love file, but the code looks horrible as it just grew over the past few hours from a small idea.
Any help in any direction would be much appreciated!
rellig