insantly stop a body in love.physics
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
insantly stop a body in love.physics
how would i stop a body in love.physics? im making a platformer game and i need the player not to slide around
Re: insantly stop a body in love.physics
For sliding over platforms we use friction (from 0 to 1)
For lowering the velocity over time (even while in the air) we use linarDamping and angularDamping (from 0 to positive infinity)
Another option is to manually set the linear/angular velocity to 0 but this will produce strange looking collisions.
For lowering the velocity over time (even while in the air) we use linarDamping and angularDamping (from 0 to positive infinity)
Another option is to manually set the linear/angular velocity to 0 but this will produce strange looking collisions.
Re: insantly stop a body in love.physics
when i use :setFriction(1) it throws an error on me that its a nil value
Re: insantly stop a body in love.physics
Maybe object before colon is not fixture?
Re: insantly stop a body in love.physics
it most certainly is a fixture
Re: insantly stop a body in love.physics
Then more code needed. ":setFriction(1)" is not enough. What else can give you nil? Of course not "1". And "setFriction" is the right name for the method.
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: insantly stop a body in love.physics
According to the wiki, only Shapes, Fixtures and Contacts have setFriction methods; the code should only return an error about that being nil if the object's not one of those.
You could post in the relevant piece of code as arampl mentioned.
You could post in the relevant piece of code as arampl mentioned.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: insantly stop a body in love.physics
Code: Select all
player.body = love.physics.newBody(world, player.spawnpoint.x, player.spawnpoint.y, "dynamic")
player.shape = love.physics.newRectangleShape(20, 20)
player.fixture = love.physics.newFixture(player.body, player.shape):setUserData("player")
Re: insantly stop a body in love.physics
I think you should split the last line into two:
Then you'll be able to use setFriction with player.fixture.
Code: Select all
player.fixture = love.physics.newFixture(player.body, player.shape)
player.fixture:setUserData("player")
Re: insantly stop a body in love.physics
god bless youarampl wrote:I think you should split the last line into two:Then you'll be able to use setFriction with player.fixture.Code: Select all
player.fixture = love.physics.newFixture(player.body, player.shape) player.fixture:setUserData("player")
Who is online
Users browsing this forum: No registered users and 0 guests