1 decade ago
by soto
I'm using box2d plugin with impactjs and I noticed that box2d doesn't seem to retain the collision data in the weltmeister collision slopes. Box2d is just seeing squares and thus characters crash right into them. Anyone know of a clean way to implement this?
1 decade ago
by soto
Thanks. I had actually seen that and tried to implement, but it looks like that is using an old version of Box2D.
I ended up using this version
https://github.com/Joncom/impact-box2d-sugar which seems to have taken care of the slope issue.
There are still a few inconsistencies I'm dealing with, but at least this fixes the slope collision issue.
soto
1 decade ago
by Joncom
Quote from soto
There are still a few inconsistencies I'm dealing with, but at least this fixes the slope collision issue.
What sort of inconsistencies?
1 decade ago
by soto
It's mainly an issue with velocity. Sometimes it just stops responding to key strokes. For example, the jump velocity of:
this.vel.y = -300;
Will randomly stop working. I don't know that this is an issue specifically related to the updated box2d lib or if something else is the cause, but it wasn't happening before.
1 decade ago
by Joncom
Can you confirm with console.log
that the jump key stroke is being registered during each press?
That would solve the following unknown:
Is the change to vel.y
having no effect, or is the key stroke not firing the change in the first place?
1 decade ago
by soto
Yes, I have confirmed that the key is being registered with console.log. This also happens on the x access as well. I have actions to move player right and left and those are also firing (The player rotation sprite is executing) but the velocity still becomes locked.
I did notice that when turning on box2d debug by including 'plugins.box2d.debug' the collision box of the player turns from a pinkish color to a dark grey. Once it turns into dark grey, which usually happens within a second or so of inactivity, that's when the velocity is no longer affected by interactivity. Although other things are triggered on the same action, such as the console log and sprite rotation.
1 decade ago
by soto
Ugh... it was the sleeping flag that was causing this issue.
This fixed it:
this.body.SetSleepingAllowed(false);
Thanks for the help. Nothing like an open thread to help you turn your brain on :)
1 decade ago
by Joncom
If using the latest
Box2D Sugar, this works too:
entity.maySleep = false;
Or, you could disable it from the start:
EntityExample = ig.Entity.extend({
maySleep: false,
init: function(x, y, settings) {
...
}
});
1 decade ago
by soto
The version that I&039;m using is still using #allowSleep
, which seems to work fine.
Page 1 of 1
« first
« previous
next ›
last »