Physics questions

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
easy82
Party member
Posts: 184
Joined: Thu Apr 18, 2013 10:46 pm
Location: Hungary

Physics questions

Post by easy82 »

Hi!

1. I'm trying to figure out what is the best way to identify a collider object when using the physics callbacks. How do you guys do it?
A) Set the UserData attribute to store 'player.one', 'player.two', 'block.simple.22', 'block.triggered.56', etc. Then I could parse the string, and use it to identify object categories to individual objects. I have never been quite keen on parsing stings though, as it tends to be slow.
B) Use Categories as enumerated object types, e.g. PLAYER = 1, BLOCK = 2, etc. and UserData to store a number to identify the individual object, then look up the object from the list with the aid of this number, i.e. objectList[number].
C) Store the "pointer" in the UserData, and cycle through the list to identify the object.
D) ???

2. The callbacks are called at least twice, I guess it's either because when the 'player' touches a 'block' then that 'block' also touches the 'player', or simply because while resolving the penetration it's called multiple times. This means playing a sound would happen multiple times when touching the block. How do you deal with this?

3. Is it a good idea to use 'kinematic' objects for doors, moving blocks, or even to restict a player movement?

Thanks in advance!
User avatar
Ragzouken
Citizen
Posts: 84
Joined: Fri Aug 10, 2012 7:59 am
Contact:

Re: Physics questions

Post by Ragzouken »

Not sure I fully understand what you're asking, but for 1. I would always store a "pointer" to a table of metadata (that table might also be the object it is describing) and I'd but some type information in there. Usually something like:

Code: Select all

local data = {
    player=true,
    blocking=false,
    object=THEACTUALTHINGTHISDATAISABOUT,
}
User avatar
easy82
Party member
Posts: 184
Joined: Thu Apr 18, 2013 10:46 pm
Location: Hungary

Re: Physics questions

Post by easy82 »

Ragzouken wrote:Not sure I fully understand what you're asking, but for 1. I would always store a "pointer" to a table of metadata (that table might also be the object it is describing) and I'd but some type information in there. Usually something like:

Code: Select all

local data = {
    player=true,
    blocking=false,
    object=THEACTUALTHINGTHISDATAISABOUT,
}
Yes! This is the simplest solution, and I haven't thought about it! :D Thanks!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 83 guests