[SOLVED] Player Sinks Into Ground After 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
User avatar
i_love_u
Prole
Posts: 28
Joined: Sat Nov 29, 2014 12:13 am

[SOLVED] Player Sinks Into Ground After Collision

Post by i_love_u »

Right now I am having an issue where my character is colliding with this fixture, which then essentially "sinks" my character into the ground. Can anyone please try my game and just jump around and hit your head on the bottom of the ledges (that's the fixture locations). You might have to try it a couple of times on the different ledges, but it will happen.

As you can see, the sprite starts off fine, but then will sink into the ground. Please help.. :cry:

See my attached files. (4)

P.S. Can anyone reiterate on what the "setUserData()" does, and if it can change the data, or be the culprit here somehow? (Is it basically just like a tag/identifier, and nothing else?)
P.S. And yes, I tried to draw the pig at the top of this page. :awesome:
Attachments
main.lua
(9.56 KiB) Downloaded 93 times
tile.png
tile.png (3.11 KiB) Viewed 3583 times
pig.png
pig.png (3.2 KiB) Viewed 3583 times
Last edited by i_love_u on Sat Dec 06, 2014 7:51 pm, edited 2 times in total.
User avatar
nfey
Citizen
Posts: 63
Joined: Tue Feb 18, 2014 9:50 am
Location: Romania

Re: fixture:setUserData()

Post by nfey »

First off, the user data can be anything. It's just a reference that you can set to whatever info you want the fixture to have, in order for you to be able to distinguish between them in the callbacks. It can be a string, or a table or an instance of a class that you wrote.

Second, you should use Azhukar's physics debug method to see what happens with your shapes when you jump around. viewtopic.php?f=5&t=77140

I'm uploading a modified version of your love that uses this debug method. Run it and see what the problem is ;)
Attachments
main.lua
(12.26 KiB) Downloaded 95 times
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Player Sinks Into Ground After Collision

Post by Azhukar »

Try this example and see if you can understand how to make it work.

http://love2d.org/forums/viewtopic.php?f=5&t=79243
User avatar
i_love_u
Prole
Posts: 28
Joined: Sat Nov 29, 2014 12:13 am

Re: Player Sinks Into Ground After Collision

Post by i_love_u »

:awesome: Thanks, it was the actual rotation of my shape, and that script helped me visualize it. I fixed it by adding this line of code:

Code: Select all

player.body:setFixedRotation(true)
:awesome: :crazy: :huh: :cool: :o:
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: [SOLVED] Player Sinks Into Ground After Collision

Post by Doctory »

this has nothing to do with the question, all i wanted to mention is that you are missing the nose holes on the pig
User avatar
i_love_u
Prole
Posts: 28
Joined: Sat Nov 29, 2014 12:13 am

Re: [SOLVED] Player Sinks Into Ground After Collision

Post by i_love_u »

Doctory wrote:this has nothing to do with the question, all i wanted to mention is that you are missing the nose holes on the pig
Hehe, and mine doesn't look fat enough like the one there. LOL :awesome:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests