Search the Community

Showing results for tags 'collision'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • 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 512 results

  1. Hey guys, I have searched all over to figure this our but no luck. How do I enable the debug to show the bounding/collision boxes on sprites in Phaser 3? this was pretty easy to do in Phaser 2 but I dont see any docs on how to do this for 3. Thanks!!!
  2. Hi Guys, AM having problems setting up collisions between children of a group I created. I can have have them collide with other gameobjects but not with each other. This is the code I have inside my Create function, am I missing something? create: function () { myObjects = this.physics.add.staticGroup(); var mychildObjects = this.textures.get('myObjects').getFrameNames(); var y=400; for (var i = 0; i < 5; i++) { var x=400; y+=260; for (var j=0; j<5; j++){ var image = this.add.image(x, y, 'myObjects', Phaser.Math.RND.pick(mychildeObjects)); image.setInteractive(); this.input.setDraggable(image); myObjects.add(image); x+=260; } } this.physics.add.overlap(myObjects, myObjects, this.checkCollision, null, this); this.input.on('drag', function (pointer, gameObject, dragX, dragY) { gameObject.x=dragX; gameObject.y=dragY; } ); }, checkCollision:function(object1, object2){ console.log("inside"); object1.destroy(); }
  3. Hello to all of you! I want to thank everyone for support on my previous issue, especially @JohnK. At that time I had(and still have because of trouble of applying his suggestion) one structural problem with performance that I am caring for a longer period of time. But that is out of the scope for the moment being because I had one little problem which troubles me a lot. Essentially from time to time when zooming out(on the maximum level) and panning the camera I have the horrendous flickering which is even more obvious than on demo due to fact that I also add transparent hole(I have not added it here for the sake of the code complexity). Issue can be seen here: https://playground.babylonjs.com/#LE1BSK#9 From my understanding the issue is happening because of some sort of weird collision between two textures ground and location one. But I really cannot afford to do any positioning change. Is there any other, more elegant way to resolve this problem? Probably I am missing something really trivial. Thanks to all
  4. Hi, I am trying to make a goalkeeper game, which require goalkeeper mesh body to be able to "block" any football that hit toward him. The best would be the mesh collider that represent the goalkeeper to be reasonably precise while not being overkill, so I created boxes, set their physics imposter, and attach them to each bone. which look like this: http://www.babylonjs-playground.com/#SRR6Y2#1 however, I don't know how to make each box collidable to the falling sphere, did I miss anything, or does it require more complex way of implementation?
  5. A general Question regarding groups / collisiongroups. Or Arcade sprites itself. I got a group of sprites "Minion" and the "level" collision group. 1. The Minions should collide with all sides:( left, up, right, down) with the levelgroup. 2. But for "Minion" vs "Minion" they should only collide top. By setting "checkCollision" I disable the collision with the level-group. Is there an easy way to archieve this behavior?
  6. Hello everyone my first day with Babylon, so please indulge. I have the same problem as Emiya0306 but not with the gltf Exporter but with the Babylon Exporter (*.babylon) I have read the whole thread, but frankly, I didn't understand very much. The Arc Rotate camera goes through my object (with middle (Scroll)Mouse-Button). I have checked Collisions for the Object and the Camera. Did I miss something? Online: http://www.experimente.bplaced.net/collisions/collisions.html The Blend: http://pasteall.org/blend/index.php?id=49326 Babylon 3.1.0 Babylon-Exporter 5.62 Blender 2.79B Many thanks in advance Hans
  7. Here is my simple playground demo. Just like the title described, Why this ArcRotate camera can go through the mesh? Is this the gltf file problem?
  8. tl;dr game.physics.startSystem(Phaser.Physics.ARCADE); GameMap = game.add.tilemap('GameMap'); GameMap.addTilesetImage('TileSet', 'TileSet'); under = GameMap.createLayer('Underground'); layer = GameMap.createLayer('TileMap'); trees = GameMap.createLayer('Collideables'); GameMap.setCollision(7,true, "TileMap" ); // Deep water 1 GameMap.setCollision(17,true, "TileMap" ); // Deep water 2 GameMap.setCollision(27, true, 'Underground'); // Darkness GameMap.setCollision(37, true, 'Collideables'); // Trees game console.logs an error " No such layer name: TileMap" So player doesn't collide with water in the begining of the game. If I switch to layer "underground" with: Player begins collision with water as if everything is okay. I also don't receive any errors about layers like "Collideables" and "Underground". I've rechecked the names in the TiledMap multiple times but can't seem to pinpoint the source of this problem. What is that all about?
  9. Hi all, Could you help how i can stop detecting collision between two sprites after detecting? this.game.physics.arcade.collide(this.animal, this.animal, this.stopanimzwierz, null, this); After collision i have function which is stop moving sprites, but sprites still staying in collision so i am not possible to start next function which is moving those sprites. Could you help me to find solution? In simple way i want to stop sprites, stop collision between them to move it again with automatically function.
  10. Her is an example based on a Phaser 2 example, 0 index is set as colliding: Her is the tiled json file: https://examples.phaser.io/assets/games/starstruck/level1.json Phaser 2 example where empty (index 0 in tiled json) is not collideable: https://phaser.io/examples/v2/games/starstruck What is the easiest way to fix this in phaser 3? Setting 0 in setCollisionByExclusion method does not exclude it from collision.
  11. ZyMonogatari

    Sprites are overlapping on collide

    Hello, Im making a game where you have to jump some cars, you only lose if you touch the left side of a car. the problem is when the character lands over a car both sprites overlap, and if another car comes behind you will collide with it instead of pass over it I'm using arcade physics. I'll let you a couple screenshoots of this. Is there some way to avoid this?
  12. Hello! I am trying to make a player to collide with the ground. But the ground has been imported from a tilemap using the tiled program. The collision is not working This is the important part of my code: collisionLayer = map.createStaticLayer('collisionLayer', tileset); var players = findObjectsByType('player', map, 'objectsLayer'); player = this.physics.add.sprite(players[0].x, players[0].y, 'dude'); this.physics.add.collider(player, collisionLayer); findObjectsByType is not a phaser native method, but it is working. The code runs without errors, but the collision is not working. I have attached the code. Thanks! example.zip
  13. Hi! What I'm trying to do is have 2 objects: one stuck on screen, and one moving with P2 physics. But from all my testing, what I've gotten down to is that I have 2 choices: 1. No collision between the objects, but able to detect when it goes out of screen or 2. Objects collide but can't detect when goes out of screen So my question is... How do I combine that? This is my code now: var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); function preload() { game.load.image('block', 'assets/block.png'); } function create() { game.stage.disableVisibilityChange = true; //keep running on lost focus game.world.setBounds(0, 0, 800, 600); game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 250; //create objects var stuck = game.add.sprite(400, 350, 'block'); var stucknon = game.add.sprite(480, 150, 'block'); game.physics.p2.enable([stuck, stucknon]); stuck.body.static = true; } If I have the code for collision groups and collisions, then it will just fall through each other and not collide at all. The reason I'm using P2 is because I want the realistic/rotating gravity effect So what do I need to add to make the moving object ("stucknon") fall through the screen and then delete it?
  14. malakiah

    Collision between sprites

    Hello, I'm developing my first application with pixi.js 4 and I have a problem with collision between sprites. In my case I use textures with irregular shapes and logically I'm able to intercept collision between rectangular sprites (using Bump library). I need instead to check collision between irregular shapes as attached example. Is there a way to create an impostor shape attached to sprite in order to have this result? Thanks for now and sorry for my bad english. Vittorio
  15. Hi !! I continue to learn this wonderful framework of BabylonJS and program an open source FPS game (should be on Github soon). I first hesitated between built-in collision system and the cannonjs physic engine : I tried both and I currently think the physical engine will better suit my needs (rocket jump ! ). I am already able to move a character, in any direction, first or third camera view, I can jump on objects, but I am facing a new problem.... => I have to detect ANY ground collision and this task is not so easy as it seems. Detecting collision with a cube is easy, but detecting collision ONLY from the top of the cube (to end a jump andplay a sound, for example) is more complicated. If I jump, I don't care about wall collision with the cube, I am interested only by the collision when my character collides from bottom. My character is a simple invisible Box. So I got some ideas : 1) create a second box for my character, a little bit smaller, just to detect collision "from bottom". xxxx xxxx <=== main box, detect wall collision xxxx ----- <=== thin bottom box of the character, detect ground collision 2) OR change scene objets where I can jump on, with a special "ground type objet" but this solution seems the most awful possible : you are not free anymore to design objects 3) OR change the way collision are detected : for example, if my position.y is decreasing AND THEN my position.y < epsilon, then it means I have collided something. With this solution I don't even need collision event : i create it myself, but it is a little but tricky to code OR ... any idea ? I will try solution 1 and will share my experience here. If anyone has an advice on this or encountered the same kind of problem plz tell us Thanks
  16. Hey guys, I'm new to phaser and I'm not quite sure if this is a bug or a mistake of myself. In this code if the player has a circle as his body and if he is colliding with one of this obstacles he won't get separated as it is described in the phaser documentation. So if you move up and collide with the obstacle the console starts printing out true even if you stop moving. In addition to that if you walk against an edge of the obstacle the player gets stuck on it and can't get away of that. I'm confused because this doesn't happen if the players body is an rectangle. Does anybody have an idea? var game = new Phaser.Game(600, 600, Phaser.AUTO, "", {preload: preload, create: create, update: update}); var player; var cursors; var obstacles; function preload(){ game.load.image("robot", "player.png", 32, 48); game.load.image("obstacle", "box.png"); } function create(){ player = game.add.sprite(game.world.centerX, game.world.centerY + 200, "robot", 5); game.stage.backgroundColor = 'rgb(239, 228, 176)'; game.physics.arcade.enable(player); player.body.setCircle(player.width/2);// player don`t get seperated in the collide function //player.body.setSize(player.width * 0.8, player.height*0.8,player.width * 0.1, player.height*0.1 ); //player get seperated in the collide function player.anchor.set(0.5); player.angle = -90; cursors = game.input.keyboard.createCursorKeys(); obstacles = game.add.group(); game.physics.arcade.enable(obstacles); obstacles.enableBody = true; obstacles.create(game.world.centerX, game.world.centerY - 200, 'obstacle'); obstacles.create(game.world.centerX - 190, game.world.centerY - 200, 'obstacle'); obstacles.create(game.world.centerX + 150, game.world.centerY - 100, 'obstacle'); obstacles.create(game.world.centerX - 130, game.world.centerY, 'obstacle'); obstacles.create(game.world.centerX - 230, game.world.centerY, 'obstacle'); obstacles.setAll('body.immovable', 'true'); obstacles.setAll('anchor.x', '0.5'); obstacles.setAll('anchor.y', '0.5'); } function update(){ game.debug.body(player); obstacles.forEach(function(item) { game.debug.body(item); }); if (cursors.up.isDown) { game.physics.arcade.velocityFromAngle(player.angle, 200, player.body.velocity); } else { player.body.velocity.set(0); } if (cursors.left.isDown) { player.body.angularVelocity = -300; } else { if (cursors.right.isDown) { player.body.angularVelocity = 300; } else { player.body.angularVelocity = 0; } } game.physics.arcade.collide(player,obstacles,(p1,en)=>{ console.log(true); }, null, this); } cheers landa
  17. madmarcel

    Phaser + Spriter - collision boxes

    Hi, Been trying to get Spriter Pro collision boxes to work in Phaser - has anyone had any luck in getting this to work? I'm close...but not quite there... This is using this plugin by the way: https://github.com/SBCGames/Spriter-Player-for-Phaser
  18. Hi everybody, I'm working on my first Phaser based game and so far it's really a lot of fun One thing that keeps giving me some headaches from time to time though is that P2 physics is mostly incompatible with arcade and many tutorials only work with arcade. That seems to start with the sprite bitmaps where everything is rotated 90 degrees Usually I find some workarounds or I've replaced stuff completely like the Weapon plugin, but now I'm facing an issue with collisions where I'm not quite sure what's the best solution: Let's assume we have 2 player sprites and 2 enemy sprites and each of them has some bullets to fire. So we create 2 collision groups for the sprites and 2 for the bullets: var playerCG = game.physics.p2.createCollisionGroup(); var enemyCG = game.physics.p2.createCollisionGroup(); var playerBulletsCG = game.physics.p2.createCollisionGroup(); var enemyBulletsCG = game.physics.p2.createCollisionGroup(); player1.body.setCollisionGroup(playerCG); player1.body.collides([enemyCG, enemyBulletsCG]); p1Bullets.body.setCollisionGroup(playerBulletsCG); p1Bullets.body.collides([enemyCG]); player2.body.setCollisionGroup(playerCG); player2.body.collides([enemyCG, enemyBulletsCG]); p2Bullets.body.setCollisionGroup(playerBulletsCG); p2Bullets.body.collides([enemyCG]); enemy1.body.setCollisionGroup(enemyCG); enemy1.body.collides([playerCG, playerBulletsCG]); e1Bullets.body.setCollisionGroup(enemyBulletsCG); e1Bullets.body.collides([playerCG]); enemy2.body.setCollisionGroup(enemyCG); enemy2.body.collides([playerCG, playerBulletsCG]); e2Bullets.body.setCollisionGroup(enemyBulletsCG); e2Bullets.body.collides([playerCG]); So far so good, that works fine. But now we want to change the play-mode and want to activate "friendly fire" and "friendly collisions". If we add the playerBulletsCG to player1.body.collides(...) and playerCG to p1Bullets.body.collides(...) we get a problem when the bullets are fired from withing the collision box of a player because the players own bullets collide now with his sprite :-( Obviously we could create additional groups like player1CG, player2CG and player1BulletsCG, player2BulletsCG, but then we also have to add all these groups to the enemies and we need to come up with a whole new structure of initializing all these groups in case we want to support 4 players or more. So I was wondering if there is any method that says "collide with anything but your own bullets"? I'm open for any suggestions :-)
  19. Im using 2.0 arcade physics for a platformer i'm making but my player keeps colliding with invisible overhead tiles , running through tiles ,and sinking into the floor. I've tried changing around numbers in my setCollisionBetween and setCollisionByExclusion but collision detection is all over the place. I never really ran into this problem with the earlier phasers. Its to the point where the game is kinda unplayable. The links below are to hastebin.com Here is my tilemap.json. I only want the player to collide with "ground"And here is my actual game code game.js is there anything i can do to fix this?
  20. julacariote

    Tile collision and gravity

    Hi everyone, I ran into a problem while prototyping a game. The game is very basic for now: the player is a 32x32 square sprite in a tilemap of 32x32 tiles. The player had to dig trough the dirt tile. Grey tiles (rocks) will fall down if there is no more dirt below them. As you can see on the screenshots, if the player remove a dirt tile below a rock, this one will start falling down and will also make the player tunneling through the dirt tiles which of course is not intended. I don't understand where the problem might be? In update, I make the player collide with rocks and the dirt tiles. update: function() { // ... this.game.physics.arcade.collide(this.player, this.layerDirt); this.game.physics.arcade.collide(this.rocks, this.layerDirt); this.game.physics.arcade.collide(this.player, this.rocks); //... }I also checked the tiles collisions attributes: collideUp is set to true for the tiles below the player. The player body is set to collide on every faces. Also, the group "rocks" has its property "allowGravity" set to false. It's only when the player remove a dirt tile below a rock that I set the allowGravity of this rock to true. But this is done all in the same frame. Creating the rocks group: create: function() { //... this.rocks = this.game.add.group(); this.rocks.enableBody = true; this.map.createFromObjects('rocks', 7, 'rock', 0, true, false, this.rocks); this.rocks.setAll('body.allowGravity', false); this.rocks.setAll('body.immovable', true); // I don't want the player to be able to push rocks //...}It seems that the falling rock gives a velocity to the player which is correct but the player should immediately collide with the dirt tile below him? I tried to play with the TILE_BIAS attribute but still no luck from 40 to 150. The value of gravity does not change anything, the problem is still here with a gravity of 10 or 300. Can anyone help me in the right direction? Thanks!
  21. Pretty straightforward question: I want to draw my collision layers in Tiled, preferrably using the Polyline tool. I would use createFromObjects, but I don't really need the polyline to appear as a sprite, or appear at all (except for debug mode as a collision layer). Phaser: 2.6.2 Physics: Arcade Create() { ... map = game.add.tilemap('mario'); map.addTilesetImage('tileset', 'tiles'); layer = map.createLayer('Tile Layer 1'); boundary = map.objects.boundaries[0]; player = game.add.sprite(map.objects.mainPlayer[0].x, map.objects.mainPlayer[0].y, 'dude'); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; ... } Update() { ... game.physics.arcade.collide(player, boundary); ...
  22. Hi I'm new to phaser and have been trying to use some of the examples as a starting point. I'm planning on using the "Pick Up Object" example, but restrict the area that the tetris shapes are placed in - so that they land on a solid platform. I would then add 3 x buttons to add more of the shapes onto the screen. Example here: https://phaser.io/examples/v2/p2-physics/pick-up-object Would the best way to achieve this be to build the solid platform using a kinematic sprite as documented here: http://phaser.io/examples/v2/p2-physics/kinematic-body If not, what is the best way define the area that the shapes are placed in - so they do not fall behind or in front of the platform and buttons? Thanks! Tom
  23. Hy there! I used a heightmap displacement on the sphere, i turned the scene collision on and checked collision for the displaced mesh but the camera doesn't collide with it. thinking maybe it has something to do with the bounding box, here's a pg: https://www.babylonjs-playground.com/#5CT9MA
  24. Let's say you have a sprite with a collision body of 16px/16px and all the areas to move in the map are exactly 16px/16px as well. It's very hard to maneuver the sprite to be at exactly in the opening to avoid collision letting the player move through it. For example, I attached a gif I made of how Bomberman solves this problem: Bomberman allows the player to clip slightly into the corner of the tile when they get close to the edge so the player starts moving diagonally into the open gap so then the player doesn't have to worry about lining up perfectly. I've looked into doing that but collision detection is AABB on tiles. I also can't just set the players x/y coordinates to be in the right spot because that will break any other collision physics going on. So is there a way to round the corners like in Bomberman or to use velocity to position the player in the opening of the lane perfectly or any other ideas I'm not thinking of? Thanks
  25. Games

    Tiled/Sprite collision

    Hi, I want to ask how to collide sprite with a tile in layer on map created in tiled. So far I have this, but it doesnt work /* global demo, game, Phaser */ demo.stateMaze = function(){}; var ball; var playerSpeed = 3; var map; demo.stateMaze.prototype = { preload: function() { game.load.tilemap('map-maze', 'assets/maps/hole_in_a_park/maze/mapa.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tileset-maze', 'assets/maps/hole_in_a_park/maze/tileset.jpg'); game.load.image('ball','assets/imgs/gula.png'); }, create: function() { game.stage.backgroundColor = '#FFFFFF'; //Starting physics game.physics.startSystem(Phaser.Physics.ARCADE); map = game.add.tilemap('map-maze'); map.addTilesetImage('tileset','tileset-maze'); //CallBACK map.setTileIndexCallback(15, this.collisionHandler(), this); normal = map.createLayer('normal'); normal.resizeWorld(); wall = map.createLayer("wall"); wall.resizeWorld(); normal.renderSettings.enableScrollDelta = true; wall.renderSettings.enableScrollDelta = true; ball = game.add.sprite(0, 80, 'ball'); ball.anchor.setTo(0.5, 0.5); //Enabling ball physics game.physics.enable(ball); game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT; game.input.onDown.add(function(){ if (game.scale.isFullScreen) { game.scale.stopFullScreen(); } else { game.scale.startFullScreen(false); } }); }, update: function() { //Collide game.physics.arcade.collide(ball, wall); if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { ball.scale.setTo(1, 1); ball.x += playerSpeed; } if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { ball.scale.setTo(-1, 1); ball.x -= playerSpeed; } if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) { ball.y -= playerSpeed; } if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { ball.y += playerSpeed; } }, collisionHandler: function() { console.log("COLLISION!!!"); } }; But it never write COLLISION!!! so can anyone tell me what to do ?