# NumberOneRobot

Members

13

• Rank
Member
1. ## Jumpthrough platforms causing bouncing

I figured out that the issue is that my course correction was changing the velocity of the ground/platform, which should be immoveable. It wasn't moving, but it seems it was causing the bouncing.
2. ## Jumpthrough platforms causing bouncing

I'm trying to create a game that involves platforms I can jump through and land on top of. However, when I jump through a platform and land on it, I bounce on top of the platform. The bouncing has to do with the height I dropped from onto the platform. In order to do the jumpthrough platforms, I used the ideas from this thread, and modified them to work with my game. The actual code I'm using in the onPreSolve method is below: world.on('preSolve', function(presolve) { for (var i = 0; i < presolve.contactEquations.length; i++) { var c = presolve.contactEquations[i] var f = presolve.frictionEquations[i]; if (c.bodyA.shapes[0].collisionGroup == GROUND || c.bodyA.shapes[0].collisionGroup == PLATFORM) { var yAxis = p2.vec2.fromValues(0, 1); var y = p2.vec2.dot(c.normalA, yAxis); if (y >= 0){ // check for jumpthrough object // check if moving upwards c.enabled = false //disable contactEquation if (f) { f.enabled = false //disable frictionEquation (solves the stuckInPlatform problem) } if (c.bodyA.velocity[1] < 15 ){ // velocity < 15 - still inside the platform c.bodyA.velocity[1] -= 5; // course correction! } } } } });The only thing that seems like it might be causing the issue would be the course correction, though I wouldn't expect that code to be executed when I am falling and land on top of a platform, since this should check if it is moving upwards on contact. If this is a common problem, please point me to the thread where I can read more about this, because I wasn't able to find it through searches. I've attached a video showing the bouncing. It's more slight in the video than usual, but sometimes it gets to the point that the character is bouncing higher than he is tall. (I apologize for the poor video quality, don't have any screen recording software installed on this computer.) IMG_1733.MOV
3. ## Undefined is not a Function in Debug Example

Changing from using phaser.min.js to using phaser.js seems to have fixed the undefined issue.
4. ## Undefined is not a Function in Debug Example

The web server I'm running is the Python SimpleHTTPServer, how do I configure it to handle JSON files? On a different note, I don't really understand why that is the issue here. From what I can see, it seems that the physics property/function of the game.load object does not exist. It is undefined when I log it in the console.

6. ## Different shapes in a single body with different collision mask

I am trying to make a combat game. I want players to collide with the ground like normal, but to interact differently when they collide with other players. To do this, I've created a body with two shapes, one that is not a sensor, and collides with the ground, and one that is a sensor, and collides with other players. When I try to have both of the shapes active on the body, however, I fall through the ground. When only the ground colliding shape is active, the ground collision happens, but the other collision (obviously) does not happen. Is this a limitation in the p2 physics engine that doesn't allow a body to have shapes with different collision masks, or or do you think there is something I am doing wrong to mess this up? Below is the code I'm using to add the shapes to the body. I set the collision mask when I load the shapes earlier in the code. for (var i = 0; i < groundCollisionShapes.length; i++) { this.body.addShape(groundCollisionShapes[i], groundCollisionShapes[i].offset);}for (var i = 0; i < playerCollisionShapes.length; i++) { this.body.addShape(playerCollisionShapes[i], playerCollisionShapes[i].offset);}
7. ## Gravity scale update delays for one timer step

Hello, I've been trying to make ground collisions for my using sensors, which means I've been having to handle collisions with the ground myself. I tried a couple things, first, I tried simply setting the velocity to 0 once I landed on the platform, but I would continue to fall through the platform. What I'm trying now is setting the gravity scale to 0, and the vertical velocity to 0 when I hit the ground. Then, when I detect input that'll make me leave the ground, I set the gravity scale back to 1, and the velocity is set based on the input. The problem is that when I hit the ground and set the scale and vertical velocity 0, my velocity isn't 0. It's 26.xxxx, which I believe is the speed from one tick of the gravity force being applied. I don't understand why this is the case, since I 0 the velocity and set the gravity scale to 0, I don't think it would affect the gravity to make it non-zero. Is the physics gravity applied later, and the gravity scale not upgraded until later in the physics loop? All my changes are in my contact event handler, and I don't know where that is in the physics loop hierarchy. If there is a better way to do these ground collisions, please let me know. I want to be able to drop through the platforms as well as land on them, and this is the best way I can come up with to do that. Thanks!
8. ## Expect collision with ground but players fall through

Hello, I'm trying to make a set of platforms in my game using the p2 physics engine. I'm using p2 on the backend, and phaser for the frontend. I have set up four platforms arranged in a column like this: ---------- ---------- x ---------- ---------- Note: The 'x' marks the center of the world. The issues I'm having is that the collisions work in one direction but not the other, for each of the four platforms. In one direction, the player correctly collides with the platform. In the other, the character gains a huge burst of speed and is shot through the platform. On the two bottom platforms, the player can fall down through the platform and get the speed burst, but not move upward through the platform. The top two platforms have the opposite issue, they shoot you upwards if you collide with them when jumping upwards, but you can properly stand on them. I think part of the issue might be where I've set the center of the map and the way I implemented the platforms. I made the map and the ground as a single physics body (maybe not a best practice but I'm really not sure), and the center of the map is what I marked as the position of the body. Each of the platforms is a polygon, and the body is marked as static. The reason I think the issue may be the body's position, is because when I move any of the platforms to the opposite side of the center, the effect of colliding with them matches the other platforms on that side of the center point. I have no idea what may be causing this, as I can't even find the p2 collision code. Any suggestions?
9. ## Assigning different body to different frames of an animation

Something I'd been considering is loading all the shapes into the body to start, then setting the sensor property to false for each shape that isn't "active" in the current frame. I would keep track of this using an array with the index (into the body's shape array) of each shape relevant to a frame, and then set the sensor property of those shapes to true, and the others to false. This seems simplest to me, and perhaps I don't quite understand what happens if the sensor property is false. I'd assume it'd just register no collision if either shape is set to be a sensor. Is this true, or is a collision registered even if only one of the shapes is a sensor? Even if only one shape is registered as a sensor, I'd assume I could just check if the other shape is a sensor, then I should be able to tell whether this is a collision I should do something about or a collision I can ignore. I'd load up all the shapes by writing an analogous function to the loadPolygon function, that'd take data from the physics editor program output and turn it into a set of shapes for an animation. Does this sound like it'd work, or does this simply reflect a misunderstanding of what exactly a sensor does?
10. ## Assigning different body to different frames of an animation

Thank you for the response! I'm a bit confused about what you mean by using "sensors instead of full colliders." I've been looking through the docs about sensors, and as far as I can tell, they're something that, when a collision is begun and again when it ends, will raise an event that can then be handled by the onBeginContact and onEndContact handlers. How to disable and enable shapes confuses me as well, but from what I understand about sensors and reading other areas on this forum, I think it means simply set the sensor property for the shape to be false and then it will not detect collisions. Please correct me if I'm wrong!
11. ## Assigning different body to different frames of an animation

I'm trying to create different bodies for my different animation frames on my spritesheet. I tried using PhysicsEditor to do this by creating a different body for each of the frames as it showed up in PhysicsEditor. When I try to put this and PhysicsInfo into my game, however, I see the entire spritesheet all the time, and no animation or movement is possible. Is this because I can't assign multiple bodies to a spritesheet? (this test was done with the example at http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game, I added the physics info putting a different polygon around each of the frames in the spritesheet using PhysicsEditor, and added the info file in the preload function) I assumed that if there was a spritesheet frame being shown, only the physics information that falls within the bounds of that frame on the spritesheet would be used, but it looks like that's not the case. If I can't assign different bodies to different frames on a spritesheet, should I instead separate the frames and have the animation then cycle through each of the different frames and change the body each time? I'm trying to animate a character for a fighting game that will have different hitboxes for different frames, but this doesn't seem to be possible without cycling through a bunch of frames and changing the hitbox on each frame. This seems like it'd take a lot of RAM if I have all this for each character and each frame, and it may be slow to change each of the bodies on each frame.
12. ## Combination of keys and taking damage in fighting game

I'm trying to make a fighting game using Phaser as well! Have you worked at all on how to create different hitboxes for each frame? I'm not sure if I should create a different collision group for each frame and then cycle through the collision groups as I cycle through animation frames, or if I should be doing something else entirely.
13. ## Changing hitbox with each animation frame

I am trying to make a game using Phaser that will have some fighting aspects to it. The problem I'm having is how to assign each frame a different set of hitboxes. I understand how I can create different hitboxes for a single frame of the animation, but how I cycle through a set of hitboxes as an animation is happening is where I run into trouble. From looking through the source code and all the examples, I couldn't find any aspect of Phaser that will support what I want, and before I get in too deep with Phaser I want to make sure this is possible. Thanks!