Jump to content

Search the Community

Showing results for tags 'collision detection'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





  1. Hello community, I'm new to babylonjs and I have a question concerning to the collision detection of holes in meshes. I want to recognize that a sphere flies through a hole (any kind of shape possible). I prepared a example with an cylinder which contains some holes (different shapes) at a random position. A sphere is moving up and down to collide with the cylinder and I want to know, if that sphere collides with a hole or with the surface of the mesh object. https://www.babylonjs-playground.com/indexStable.html#1ZQS9W#6 At the moment, the collision with the mesh object change
  2. Hi everyone, I just wanted to share a new Phaser Plugin called phaser-tilemap-plus, that extends the tilemap loader and factory to support tile animations defined in the Tiled editor. It also allows you to implement collision detection against the map using polygons and rectangles within an object layer, enabling the use of sloped and curved surfaces. It will eventually also support custom properties and region-based events via the object layer. You can access and build the library from GitHub or install it directly as a Node package via NPM. Please note that it is still a work
  3. Hi guys, I've been digging through the code, examples and the forums and I'm yet to discover a solution to my problem. I have an array of objects and have set their collision properties as follows: this.physics.add.overlap(this.ball, this.bricks, this.hitBrick, null, this); What I need is to be able to dynamically change the collision type to something like: this.physics.add.collider(this.ball, this.bricks, this.hitBrick, null, this); Is there any way I can achieve that? Many thanks
  4. I am having some problems with a game where players enter safe and danger zones... some of these areas have sprites that are angled (rotated) but appear to fire collision when the 'character' sprite collides with their total X Y rectangle space (ie minXpoint to maxXpoint, minYpoint to maxYpoint)[imagine an angled rectangle pushing out its boundaries by its 4 corners] would this be right? Or am I having other issues? TO counter act i guess I will have to create n number of collision boxes (sides parallel to X-Y axe) overlapping along angleX.
  5. Hello, I am making a game using this tutorial: https://gamedevacademy.org/how-to-make-an-infinitely-scrolling-game-with-phaser/ I made some changes to it using the Phaser Basic Project template. I am having a problem with the collision detection. In the update function I have these lines detecting if a collision has happened: update: function () { console.log("in the update function!!!!!!!!!"); // Honestly, just about anything could go here. It's YOUR game after all. // Eat your heart out! // player land on ground instead
  6. This has to be a FAQ, but I did not find an answer from a quick search. I will number the questions for reference. 1. If I want a sprite to have a separate collision rectangle that is smaller than the size of the sprite, how is that done in Phaser? 2. What if I want to have more than one collision rectangle for an unusual shape? 3. What if I want to check for collisions with triangles, circles, ellipses, etc? Are there ready-to-go functions for these situations? If not, where would I plug in a handwritten algorithm? 4. If I wanted to have thousands of objects running around a huge map,
  7. Hello all, I've been working through a project (using a lot of advice I've found from lurking here) and I've run into an issue. My goals are pretty modest; I'm trying to 1) have a natural jumping mechanism, and 2) have collision detection between the camera, ground, walls, etc. At first I did this just using Babylon's .checkCollisions, which works very well for camera vs object and camera vs wall collisions. However, I couldn't get this to work properly for jumping. Even following other's tutorials, (http://www.html5gamedevs.com/topic/12198-camera-jump/) I wasn't getting the results
  8. Hi all, I'm working on a little racing game and using this map: I'm using p2 physics. Whenever the car touches the gras it should become slower. In order to achieve that I cut out the inner gras and created a polygon shape for it. /*Adding car*/ car = game.add.sprite(1100,300,'car'); car.name="car"; car.width=100; car.height=175; game.physics.p2.enable(car); car.body.angle = 90; game.camera.follow(car); inner_gras = game.add.sprite(1320, 940, 'gras'); game.physics.p2.enable(inner_gras); inner_gras.body.kinematic = true; inner_gras.
  9. hi all, When ever we make collision check it will take the width and height of the image or object which we are giving . Now can we change width and height of the collision check alone .in my case my image size is 100*100 but while dragging and droping i am making collision check in which it taking 100*100 for check but i wana change it to 200*200 can it be possible . i tried changing the image with and height while dragstart,dragmove and pointerdown ,but still for collision it will take 100*100 only
  10. Hi, I'm running into an issue regarding collision detection against adjacent DisplayObjects. Let's say I have sibling objects that are a child of a Container that has been rotated. If I use getBounds() on the siblings they return a bounding box that is oriented to cardinal north. Using those bounds for collision detection may result in false positives, because the given bounds may not follow the actual shape and orientation of the DisplayObject. I created a codepen to illustrate the point: When you toggle the "rotate" buttons at the bottom of the pen you will see the purple box morp
  11. Hey! I have a group of enemies created like this (called from create()): spawnEnemies: function(map){ this.enemies = this.game.add.group(); this.enemies.enableBody = true; this.game.physics.arcade.enable(this.enemies); var enemyStartPositions = this.findObjectsByType('enemyStart', this.map, 'objectLayer'); for(var i = 0; i < enemyStartPositions.length; i++){ var enemyStart = enemyStartPositions[i]; var enemy = new Enemy(this.game, enemyStart.x, enemyStart.y, 'cultist'); enemy.countStats(); this.enemies.add(enemy); } this.enemies.setAll("body.immovable", true
  12. Hi folks, I'm new to this forum but I was wondering if someone could point me in the right direction or to a tutorial that'll help me out? I can't seem to get the collision detection to work here. This is my code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }, true); function preload() { game.load.image('shot', 'assets/sprites/drop.png'); game.load.image('spaceship', 'assets/sprites/spaceship.png'); game.load.image('glass', 'assets/sprites/glass.png');
  13. Hey guys... Anybody got on insights on how the mesh.onPhysicsColiide property is supposed to work ??? I have this code to detect when two meshes with physics state enabled collide with each other. Now in the scene... both mesh actually do collide and bounce off each other like it should... but the the mesh.onPhysicsCollide property i set is NOT firing off. Here is code to log the collision event to the console (BUT I GET NOTHING ) // Physcis collision this.mesh.onPhysicsCollide = (collider:BABYLON.AbstractMesh, contact:any) => { console.log("*** HOLY SHIT - I GOT COLLISION *
  14. I really need to be able to hook into physics collision detection... There used to be a mesh.onPhysicsCollide that would have worked perfectly for my collision detection system (I basically don't require the imposter filter part for collision detection... I will filter based off mesh.metadata tags). Now using the registerOnPyhsicsCollide DOES NOT WORK without some kind of imposter (even with the otherImposter.length === 0). The problem is the unregister DOES NOT find if you pass null imposter or empty imposter array... you gotta pass an actual imposter to filter or you WONT be able to unregis
  15. Hi, I'm using Phaser (2.2.1) to make my first game, a platformer. Arcade physics to do the collision detection; Tiled to make the map. The problem I'm having is that the player occasionally passes through a platform when descending from a higher point (after jumping for example). Here are what I think are the relevant bits of code: Create: this.gravity = 2200;this.blockedLayer = this.map.createLayer('blockedLayer');this.map.setCollisionBetween(1,10000,true,'blockedLayer');this.player = this.add.sprite(200,200,'player');this.player.anchor.setTo(0.5,1);this.physics.arcade.enable(this.player)
  16. What is the best approach to determining what face of a mesh was hit in a collision? I'm creating a game in which there are very many meshes; they are platforms onto which the player can jump. But if the player hits the side of any platform, he dies. As far as I can think, there are two approaches here: 1. Find some way of determining which vertex set was hit, get the normal to it, and record whether the normal points in the (0,1,0) direction (OK) or otherwise (kills player). However, I can only find a way of telling when two meshes collide. The PhysicsImpostor.registerOnPhysi
  17. After half a day of debugging, I am quite sure the issue is not in my code since it comes directly out of Phaser. I attached a screenshot. The characters collide at the green C marked position. But there is nothing to collide with. The <obj>.body.blocked.left property is set to true >> so they are colliding left This shouldn't be possible. Since there is no object (green mark C) So I debugged the Phaser functions for collision. The call comes out of: https://github.com/photonstorm/phaser/blob/v2.6.2/src/physics/arcade/TilemapCollision.js#L356 (thanks to @Claudiovc )
  18. Hi, I need to implement a check that can determine if a bounding box is completely inside a set of bounding boxes. See my attached graphic for a better understanding of the situation. I am thinking of consuming the A to B paths on each axis of the original bounding box using the axes limits of the containing bounding boxes. Then, for each axis, I would store those in an array, sort them by starting point, find if there are overlaps, eliminate them, find gaps (could probably happen if outer bounding boxes are not adjacent to each other) and if none are there, look if the total le
  19. I have been working with Phaser for about 6 months now, and have recently purchased the Box2D plugin, and for the most part its great, although I am having a few basic problems with spawning the sprite with an appropriately sized body, then applying a continuous velocity. Below is the offending function. First a sprite is spawned from a loaded atlas (the zombie), but unfortunately the sprite is way too big (or my game is too small, one of them) and needs to be scaled down to a 1/4 of its original size. I found a question elsewhere on here where someone (it may have even been Rich) gave an
  20. Hi all, I'm making a mobile game and looking for the most efficient way of going about coding the following. Any comments would be most welcome 1. A solid background image Is this just a sprite of an optimized bitmap? Or is there a special method for bg images that keeps them as efficient as possible. 2. Generate a lot of balls (sprites) that bounce around the screen (Currently created a group for the balls and MANUALLY checking for boundary collisions to avoid the overhead of any physics engine). Am I being too harsh here? Will ARCADE physics do a better job of it, efficiency wise? 3
  21. Hello all, I'm trying to make a "game" in which you drag sticks from a pool and you position them on the screen. (I'm basicaly creating a cuisenaire program). The sticks have to be restrained in the underneath tilemap and also cannot overlap with each other. Every stick has a sprite.input.enableDrag(); sprite.input.enableSnap(30, 30, true, true); So it can be draggable. Also, I whenever the user drags a stick from the pool, I clone a stick there so he can drag another one later on. How can I instruct phaser to watch for collisions between all sticks? If I put them on a group, I l
  22. I am making a game, everything works except the physics system? Collisions and Gravity are in the code but don’t seem to work. Using breakpoints, it gets to all the pieces of code but never actually works. I have tried to frantically make it work (Thats why theres so much physics code in the file). Can anyone please help me? This is the code that I think you will need: http://pastebin.com/0Sh8pqVJ This is all of the code together: http://pastebin.com/CfFuatdt Thanks.
  23. Hey there, my game consists of a player implemented with P2 and enemies implemented with Arcade physics (for better performance, since the AABB is sufficient for them). How can I detect collision between the Arcade bodies and the P2 body/bodies ? (The point is: I want the enemies to bounce away) OR: I've read in some other thread, that P2 offers AABB. I've searched the Phaser docs, but I didn't find anything helpful. Can you recommend a way to implement the described above only with P2, without affecting performance? Thank you guys in advance!
  24. I'm trying to detect a possible collision between objects that could be stationary or moving in any direction (angle). 1. I want the object to be notified when a particle/object is inbound for collision. Essentially, I want to introduce AI where the object will take action when it is shot at or an enemy is approaching. 2. Another use-case is for scanning. I'd like an entity to be able to spot its enemies and get info like distance, velocity, type, etc. I've read through the documentation, examples, posts on the forum and searched online, but I've clearly missed something. Does anyone k
  25. Hi, This is my first post. I have done a search for this but I haven't found anything that specifically answers what feels like a basic question. I'm developing my first game using phaser, it basically involves a character running along a rope and collecting things. The character jumps up and down and the objects come on at two different heights. It's a pretty basic game. So, what I'd like to know is: Is it possible to have physics bodies pass through one another. Specifically what I'd like is to be able to register the characters collision with the object but then have the object pass
  • Create New...