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
    • 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 517 results

  1. Playground demonstrating the issue: https://playground.babylonjs.com/#9JSLE2 Explanation: I'm trying to create a simple walk around scene and the built in collision system seems to work pretty darn well (Who needs a physics engine anyway?) but I've noticed that when I add any kind of slope the camera will slide down it -- in a real hurry too if gravity is set realistically! I noticed that this doesn't happen with the stairs in the Espilit demo, but looking at the scene file and demo.js I can't figure out how it's managing that. Is there a friction setting or something that I can set for objects like stairs and ramps?
  2. Hello all, I feel as though I'm being hard of thinking here. Here's a PG: http://www.babylonjs-playground.com/#3ENM44#1 How do I make any one of the boxes stop moving when it hits another? I have got as far as it logging to the console when the ellipsoids collide - not what i want though. This needs to be accurate to .001 scene units (a millimetre for my setup). Think I'm going about this the wrong way. Importantly, I need to get this working with the gizmo. Any help would be much appreciated. Thank you.
  3. Hello, I am quite new to phaser and Tiled. I was wondering if anyone could give me some help with understanding on how to create tilemap collisions that are more than just squares with the p2 physics system. Right now every tile has a square collision box, I would like the collision shape to match the tile shape so that I can have slopes and what not. I am a quite a bit confused on the Tiled to phaser workflow especially on what p2.convertTilemap does and how Tiled's collision editor ties into phaser. So far my code looks like this: preload: function () { this.game.load.image('mapTiles', "assets/platformer-pack-redux-360-assets/Spritesheets/spritesheet_ground.png"); this.game.load.tilemap('level1', "assets/testmap2.json", null, Phaser.Tilemap.TILED_JSON); this.game.load.spritesheet('player', "assets/kenney_platformercharacters/PNG/Player/player_tilesheet.png", 80,110, 24); }, create: function () { this.game.physics.startSystem(Phaser.Physics.P2JS); var level1 = this.game.add.tilemap('level1'); level1.addTilesetImage('spritesheet_ground', 'mapTiles'); var wallsLayer = level1.createLayer("layer1"); wallsLayer.resizeWorld(); level1.setCollisionByExclusion([],true,'layer1'); this.game.physics.p2.convertTilemap(level1,wallsLayer); this.game.physics.p2.convertCollisionObjects(level1,"objectLayer1"); player = this.game.add.sprite(110,80, 'player'); var walk = player.animations.add('walk', [0]); player.animations.play('walk', 10, true); this.game.physics.p2.enable(player); this.game.camera.follow(player); player.body.setZeroDamping(); player.body.fixedRotation = true; this.game.physics.p2.setBoundsToWorld(true,true,true,true,false); cursors = this.game.input.keyboard.createCursorKeys(); wallsLayer.debug = true; player.body.debug = true; }, Any help is appreciated!
  4. Hello, I'm using Phaser 3 and the physics engine matter. I need to call a function when one object collides with a particular object. For example I have a tank, barrels, hearts. Then there will be bullets, other tanks, some other objects. You need to call the function when the tank collides with the barrel, it should explode, and if it collides with the heart, it will replenish life. this.matter.world.on('collisionstart', function (event) { bangBarrel(); }); this method calls the function in any collision. How to trigger the function when the tank collide with the barrel, and how to trigger the function when the tank collide with the heart?
  5. 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
  6. https://www.babylonjs-playground.com/#SVHR8A I'm trying to create a simple (at least in my mind) scene where I have a ball rolling within the confines of a single mesh "room" I built in blender and exported as .gltf. However, no matter what I do, the ball seems to always go through the imported mesh and hit the ground below (which I kept to make sure the ball doesn't fall forever). Am I doing something wrong? In the playground there isn't a physics engine but locally I've tried cannon.js after reading that it supports MeshImpostors but I get the same result with or without a physics engine.
  7. hg_tg

    Recursive Collision

    Hi all, I have been stuck for some time on procedurally generating levels for my game. As it stands, I have created rooms in a confined space but most of them overlap. Although this is expected, I can't find a way to separate them. My attempts have been centered around physics collisions, but I have failed hard. Here is my current code: Level.prototype.separate = function() { //For Convenince sake var arcade = this.game.physics.arcade, rooms = this.rooms; for ( var i = 0; i < rooms.length - 1; i++ ) { while ( arcade.intersects( rooms[ i ], rooms[ i + 1 ] ) ) { arcade.collide( rooms[ i ], rooms[ i + 1 ] ); } } //For testing purposes this.displayLevel(); }, Level.prototype.create = function() { this.game.physics.arcade.enable( this.rooms ); this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; //Gets coordinates and dimensions for Rooms and creates them. this.createLevel(); console.log( "Level State Completed" ); //this.game.state.start( 'InGameState' ); }, Level.prototype.update = function() { this.separate(); } This doesn't work. It results in an infinite loop. I have tried used Arcade's overlap as well. The issues I have had boil down to these two questions: 1. How can I test for individual room collisions when they sit in an array together? 2. When two rooms collide with one another, one or both of the rooms may still be colliding with other rooms. However, Arcade's collide method isn't recursive, and throwing the separate function into update might not guarantee the rooms be separated and hurts performance. Does anyone have any ideas or potential solutions to this?
  8. 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
  9. 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!!!
  10. 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(); }
  11. Doug

    Hi Rich.  @rgk mentioned that you might be able to please add a "patron" badge to my forum profile?  Thanks very much!

  12. 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
  13. 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?
  14. 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?
  15. 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?
  16. 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.
  17. 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.
  18. 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?
  19. 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?
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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 :-)
  25. 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?