This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by drewhjava

I just wanted to say I'm really liking impactjs so far but changing hitboxes based on certain animations has proved to be really frustrating(and frankly I've taken this for granted in other frameworks).

Jumping was not as bad. I had to add a little code to my handleMovementTrace method to subtract the position when the player hit the ground so he wouldn't fall through(being that the jumping animation has a much smaller hitbox then standing.

if (this.isJumping && (res.collision.y || res.collision.slope)) {				
				this.isJumping = false;
				this.vel.y = 0;	
				this.accel.y = 0;				
				this.pos.y =  this.pos.y - 20;	

The crouching has been next to impossible. I'm trying to change the hit box to a much smaller hit box(as I have in the jumping animation). When I hit crouch it changes the animation the hit box. Since the hit box is much smaller the player goes into the falling animation because the velocity is greater than 0(the hit box is off the ground).

I have tried changing offsets(as I did in jumping) adding velocity, position, etc. Nothing I've done get's me where I want to be.

It seems like if I could shrink the hit box from the top instead of the whole thing that would help.

Something like a 4 point size of a hit box. I'm not to sure on the specifics but It seems the hit box should be tied to an animation frame just like a time is tied to an animation(although time should be per frame. it's currently not like that).

If anyone has an suggestions that would be great. Thanks.

1 decade ago by dominic

Use the debug mode and enable Show Collision Boxes. This should help you understanding what's going on when you change the entity's size, offset and animation.

Btw.: :)

1 decade ago by drewhjava

Hey Dominic, thanks for the reply. I've already viewed all the topics on crouching and I do develop in debug mode. The problem that is happening is when I change the box size for a crouch it lifts the player off the ground therefore the player goes into the fall animation. Even if I push the player down via pos.x. I didn't know if anyone is running into this.

1 decade ago by stahlmanDesign

I also encountered this situation, but I made a phaseTransitionTimer that annuls falling animation while you transition from standing to crouching and vice-versa.

Basically, made a timer that is triggered when you stand up or crouch. During the time it takes for the collision box to fall or rise, you set anims to whatever you want, overriding the unwanted falling animation.

1 decade ago by quidmonkey

Whenever you extend offset.y, you'll also need to extend your size.y. So when you crouch, if you want your offset.y to be 8 pixels from the top, you'll also need to add 8 pixels to the size.y. When the player stands back up, you'll need to subtract the 8 from offset.y and scale size.y by the same factor.

1 decade ago by drewhjava

Either way if I override the falling animation the player still has to fall to the ground because the hitbox is higher up than it was originally. I've put a velocity of 40000 to see if I can get it to crouch instantly and it works but it messes up when he comes out of crouch. The stand up animation is through the floor.

Has no one else run into this? Seems pretty basic. Thanks
Page 1 of 1
« first « previous next › last »