Search the Community

Showing results for tags 'revoluteconstraint'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 4 results

  1. Hello! I had a look at the forum and couldn't find any advice on this previously (/I don't know the terminology to look up) so I thought I would post and see if anyone could give advice. I am using revolute constraints in my project because I wanted, as you can image, a joint that allows rotation and allows the player to rotate it with keys. The issue is that they are just flopping around the revolution instead of being rigid until the player turns them. I went through the documentation and found other types of constrains, like lock constraints, but they don't seem to work, and I have even tried turning off gravity for the arms to see if that was the issue to no luck. The code for the constraints is below, and I am sure I am missing something obvious so any advice would be great! backConstraint = game.physics.p2.createRevoluteConstraint(player, [-5,-20], backArm, [-20,0.5]); frontConstraint = game.physics.p2.createRevoluteConstraint(player, [-5,-20], frontArm, [-20,0.5]);
  2. Hello! I had a look at the forum and couldn't find any advice on this previously (/I don't know the terminology to look up) so I thought I would post and see if anyone could give advice. I am using revolute constraints in my project because I wanted, as you can image, a joint that allows rotation and allows the player to rotate it with keys. The issue is that they are just flopping around the revolution instead of being rigid until the player turns them. I went through the documentation and found other types of constrains, like lock constraints, but they don't seem to work, and I have even tried turning off gravity for the arms to see if that was the issue to no luck. The code for the constraints is below, and I am sure I am missing something obvious so any advice would be great! backConstraint = game.physics.p2.createRevoluteConstraint(player, [-5,-20], backArm, [-20,0.5]); frontConstraint = game.physics.p2.createRevoluteConstraint(player, [-5,-20], frontArm, [-20,0.5]);
  3. The following code produces a flipper and four balls that seem to interact as they should. They all collide with each other and the game world bounds. The problem is that the motor isn't working, nor can I figure out how to limit the rotation of the flipper. The flipper goes to the location of the mouseDown event. It is not fixed to a place on the board. This is my intention. I want to use a flipper wherever the player taps and holds. Thank you. window.onload = function() { var game = new Phaser.Game(800, 300, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('flipper', 'assets/sprites/flipper.png'); game.load.image('ball', 'assets/sprites/ball-transparent.png'); // Load our physics data exported from PhysicsEditor game.load.physics('physics_data', 'assets/physics/sprites.json'); } var flipper, flipper_joint, flipper_constraint; var cursors, input_body; var constraint, input_constraint; var constraint_count = 0; var ball1, ball2; function create() { game.stage.backgroundColor = "#f2f2f2"; game.world.setBounds(0, 0, 800, 300); game.physics.startSystem(Phaser.Physics.P2JS); // Turn on impact events for the world, // without this we get no collision callbacks game.physics.p2.setImpactEvents(true); game.physics.p2.updateBoundsCollisionGroup(); game.physics.p2.gravity.y = 10; cursors = game.input.keyboard.createCursorKeys(); // Create our collision groups. One for the flipper, one for the balls var flipper_collision_group = game.physics.p2.createCollisionGroup(); var ball_collision_group = game.physics.p2.createCollisionGroup(); // create joint for flipper flipper_joint = game.add.sprite(200, 150, ''); game.physics.p2.enable(flipper_joint, true); flipper_joint.body.setCircle(25); flipper_joint.body.data.gravityScale = 0; flipper_joint.body.clearCollision(true, true); flipper = game.add.sprite(200, 150, 'flipper'); game.physics.p2.enable(flipper, true); flipper.body.clearShapes(); flipper.body.loadPolygon('physics_data', 'flipper'); flipper.body.data.gravityScale = 0; flipper.body.setCollisionGroup(flipper_collision_group); flipper.body.angle = -35; flipper_constraint = game.physics.p2.createRevoluteConstraint( flipper_joint, [0,0], flipper, [-60,-30] ); input_body = game.add.sprite(0, 0, '', 0); game.physics.p2.enable(input_body, true); input_body.body.setCircle(20); input_body.body.setCollisionGroup(flipper_collision_group); var balls = game.add.group(); balls.enableBody = true; balls.physicsBodyType = Phaser.Physics.P2JS; for (var i = 0; i < 4; i++) { var ball = balls.create(game.world.randomX, game.world.randomY, 'ball'); ball.body.setCircle(25); ball.body.setCollisionGroup(ball_collision_group); ball.body.collides([ball_collision_group, flipper_collision_group]); } // set upper and lower limits for angle in the constraint // NOTE not working flipper_constraint.upperLimitEnabled = true; flipper_constraint.lowerLimitEnabled = true; flipper_constraint.lowerLimit = 0; flipper_constraint.upperLimit = -35; // Not working flipper_constraint.setMotorSpeed(100); } function update() { input_body.body.x = game.input.x; input_body.body.y = game.input.y; if (game.input.activePointer.isDown) { if (constraint_count == 0) { input_constraint = game.physics.p2.createRevoluteConstraint( flipper.body, [0,0], input_body, [0,0], 1000 ); flipper_constraint.enableMotor(); constraint_count = 1; } else if (constraint_count == 1) { flipper_constraint.disableMotor(); game.physics.p2.removeConstraint(input_constraint); constraint_count = 0; } } else { if (constraint_count == 1) { game.physics.p2.removeConstraint(input_constraint); } constraint_count = 0; } } function render() { } }; // end window.onload
  4. So, i'm trying to make a top-view car game prototype using the P2 physics engine and i've faced some weird bug? with the RevoluteConstraints. The idea is simple: create a car body sprite, create two tires and attach them to the car body, then apply car physics simulation on those tires and let the body follow. And the problem is that when tires are joint to the car, they are positioned wrong (which is weird) + the car starts rotating and the reason for that i just can't understand as: tires are positioned symmetrically + both RevoluteConstraints have the same forces that should be applied to constrain the bodies. May be i'm getting something wrong? I wouldn't make this topic if there were more advanced examples covering the P2 physics or at least examples in the docs/source code (yep, i've already googled for a solution). Here's a picture And here's the code (also available here http://pastebin.com/qjqeF5bc):