Search the Community

Showing results for tags 'Collisions'.



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 69 results

  1. Hi. I have a scene which I explore with a freecamera but I want the camera not cross the floor and the walls and remain at the same level (without going up or down) how can I do this? Thank you very much.
  2. Hello everyone, I'm working in a sokoban-like game and in this kind of game you need to reduce the player mobility to single tiles. I implemented this restriction using tween to change the x and y coordinates of the sprite along the time. When I did this I realized that the player didn't collide with the tiles, so I read the forum and someone said that the arcade physics engine doesn't detect collisions unless the velocity of the player is distinct than 0. I tried moving the sprite through velocity then but for some weird reason I still can not make the arcade engine detects collisions between the tiles and the hero. What could I be doing wrong? Did I miss something else? Here you can see the play.js code: var playState = { create: function() { this.map = null; this.player = null; this.map = game.add.tilemap(game.global.level.toString()); this.map.addTilesetImage('walls', 'walls'); this.map.addTilesetImage('grounds', 'grounds'); groups.walls = this.map.createLayer('Walls'); this.map.createLayer('Grounds'); this.map.setCollisionBetween(1, 18, true, 'Walls'); var e = this.map.objects['Hero'][0]; var y = e.y - this.map.tileHeight; var color = e.properties.color; this.player = new Hero(e.x, y); groups.walls.debug = true;}; And here is the player's code:var Hero = function(x, y, color) { Phaser.Sprite.call(this, game, x, y, 'hero', 0); game.physics.arcade.enable(this); this.body.allowGravity = false; this.cursors = game.input.keyboard.createCursorKeys(); this.animations.add('down-' + capsuleType.RED, [0, 1, 2], 12, true); this.animations.add('left-' + capsuleType.RED, [3, 4, 5], 12, true); this.animations.add('right-' + capsuleType.RED, [6, 7, 8], 12, true); this.animations.add('up-' + capsuleType.RED, [9, 10, 11], 12, true); this.color = 'red'; this.walking = false; this.nextX = null; this.nextY = null; game.add.existing(this);};Hero.prototype = Object.create(Phaser.Sprite.prototype);Hero.prototype.constructor = Hero;Hero.prototype.update = function() { game.physics.arcade.collide(this, groups.walls); this.body.velocity.x = 0; if (!this.walking) { var xDir = (this.cursors.left.isDown ? -1 : (this.cursors.right.isDown ? 1: 0)); var yDir = (this.cursors.up.isDown ? -1 : (this.cursors.down.isDown ? 1: 0)); if (yDir !== 0) { this.move(null, yDir); } else if (xDir !== 0) { this.move(xDir, null); } }};Hero.prototype.move = function(xDir, yDir) { var newX, newY, frame, direction; if (yDir) { direction = (yDir > 0) ? 'down' : 'up'; frame = (yDir > 0) ? 0 : 9; newX = this.x; newY = this.y + Math.floor(tileSize * yDir) } else if (xDir) { direction = (xDir > 0) ? 'right' : 'left'; frame = (xDir > 0) ? 6 : 3; newX = this.x + Math.floor(tileSize * xDir); newY = this.y; }};Thanks in advance for your help
  3. Hi again I had quite some fun playing around with moveWithCollisions based on an example from dad72 (this one: http://www.castorengine.com/babylon/moveCharacter/). I added some kind of mouse/click control. so if you click somewhere the cube moves there. Now I want ramps to walk up on stuff. Took me a while, probably bad programming, anyways... works. Now jumping down from the ramp works, too, as long as you land on the ground or the big cube. But if you try to jump from the big ramp onto the smaller ramp it get stuck somehow. To illustrate it I added lines that show a raycast from the green cube downwards. Please have a look at this: http://p215008.mittwaldserver.info/moveWithCollisions/ (moving too much slows it down pretty bad because of all the lines.. I know, bad programming, but ignore that for now and consider reloading the scene if it gets too slow ) Questions: 1) on the ramp the lines for the raycast are much shorter... I don't really understand why... why? 2) jumping from the big to the small ramp you see that the green box doesn't move as expected...what am I seeing here? It's not the bounding box of the ramp, is it? I assume it has something to do with the rotation? 3) how do I make it work? (I thought I needed a third... so I put that here) As I said, it's big fun again and I think it looks pretty cool. I like all those lines even if they ruin the performance... well, it's past 4am here and I might be a bit tired so forgive me if this post is overwhelmingly full of nonsense. Can't wait for your input guys! ... but have too sleep now
  4. Hi Guys, I am building a system where I load tiles of a terrain by demand. Depending of where the camera is, I create new GroudMeshes as needed and tile it on the terrain. My Tiles are a json object with altitude data and some other values. I am facing a problem after loading the grounds. I cannot see any error and the grounds are loaded but they are "not visible" and depending of the angle of the camera they appear in the scene and disappear. They should also be checking collisions but they are not. I have a running example of my system, for simplicity I am always loading the same json but the control of the tiles and the rest are the same. https://dl.dropboxusercontent.com/u/63244599/CollisionsAndVisibility/CollisionsAndVisibility.html To see the problem just click on the link after loading try to move the camera arround (keep the same position) looking in a 20 degree down aprox. and You will see the ground, if you are lucky :S According with my testing, it seems to be something related with loading the meshes during the "before render" or "render" events. If I load all of them before start running the scene. It looks ok. I can also provide you with a zip file that includes the folder and all the files. Any ideas?
  5. Hello, Since some month, I have discover Babylon.js framework, and it's a very good work for developper. In my project to learn this framework, I have load a ground with wall and a cube to simulate a person. I have activate all collisions for all meshes, physics (mass, shape: box) and export with the extension blender. I have test in sandox offline and my blender file work. After, I have create a script in JS and all meshes are load successfuly, but collisions doesn't work! I have find a tutoriel who need to create a bounding box to use .intersectsMesh(), but nothing work too. I think I have forget something, but I don't see. Can you help me, plz? Thank you very much. Here the begin of my project to undestand my problem and see scripts: https://www.dropbox.com/s/mrhvdujzwqg63mb/testBabylon.rar?dl=0
  6. My game is top-down with the player fixed in the middle. I do have a Tiled JSON data file loading fine in my game and I have a "player" sprite moving around and colliding with the tiles, but it's colliding with the clear areas around the walls, not the actual solid bits. Can someone point me to a tutorial that shows how to create collision polygons in Tiled Map Editor? I've been fiddling with an Object Layer and the Collision Editor but nothing actually happens. Meaning, I can "fiddle" with the collision editor but see no way to save the polygons I'm drawing around the tiles so I can export the data into a Tiled JSON file. Then how do I define a collision polygon for my player? It's not a square and has a lot of clear bits too. My searching has been pretty unproductive so far :-/ Thanks a lot for helping :-)
  7. Hi, I m trying to figure out how to establish a collision check with Oimo, basically what I want to do is: I have a sphere and when it collides with anything, I want to add an impulse to make it bounce up again. (The result should be like this: http://analogmadness.com/Demo/ThreeJS ) Is there any method or event that one could listen to? It would be really nice if there were any tutorials for Oimo, it seems after all more capeable than cannon.js
  8. I am new to Phaser and I am currently working on my first game. I'm am creating a vertical scroller and have come across some performance issues on mobile. I have a 1024x4608 background with some 'land' that needs collision detection with the 'player' and the 'enemies' in the game. I've been trying a couple approaches but can't seem to find the sweet spot with the performance. I was hoping someone would have some suggestions. Here's what I've tried so far: 1) Tilemap this.load.tilemap('level01_map', 'assets/level01_map.json', null, Phaser.Tilemap.TILED_JSON);this.load.image('tiles', 'assets/tiles.png');this.map = this.add.tilemap('level01_map');this.map.addTilesetImage('main', 'tiles');this.map.createLayer('land');this.world.setBounds(0, 0, this.map.widthInPixels, this.map.heightInPixels);this.map.setCollisionByExclusion([], true, 'land');var bodyObjects = this.physics.p2.convertTilemap(this.map, 'land');for(var i = 0; i < bodyObjects.length; i++) { bodyObjects[i].setCollisionGroup(this.gameGroups.landCG); bodyObjects[i].collides(this.gameGroups.playerCG); bodyObjects[i].collides(this.gameGroups.enemyCG);} 2) Sprite with polygons this.load.image('level01', 'assets/level01.png');this.load.physics('level01_physics', 'assets/level01.json');this.world.setBounds(0, 0, 1024, 4608);this.map = this.add.sprite(0, 0, 'level01');this.map.widthInPixels = 1024;this.map.heightInPixels = 4608;var polygonCollisionSprite = this.add.sprite(15, 15);this.physics.p2.enableBody(polygonCollisionSprite, true);polygonCollisionSprite.fixedRotation = true;polygonCollisionSprite.body.motionState = Phaser.Physics.P2.Body.STATIC;polygonCollisionSprite.body.clearShapes();polygonCollisionSprite.body.loadPolygon('level01_physics', 'level01_left');polygonCollisionSprite.body.loadPolygon('level01_physics', 'level01_right');polygonCollisionSprite.body.setCollisionGroup(this.gameGroups.landCG);polygonCollisionSprite.body.collides(this.gameGroups.playerCG);polygonCollisionSprite.body.collides(this.gameGroups.enemyCG); And here are my results testing on an iPhone 5:Tilemap no collisions = 45fps Tilemap with collisions = 20fps Sprite/polygons no collisions = 45fps evens out to 60fps when less polygons in view Sprite/polygons with collisions = 8fps Sprite/polygons (simple) no collisions = 60fps Sprite/polygons (simple) with collisions = 30fps Note: simple means I reduced the vertices in the polygons. (Simple = 6 shapes, Normal = 44 shapes) The game is setup with 1024x640 in Phaser.CANVAS mode. Also, the all sprite assets, except the stuff for the background, are being load via one atlas texture. Any thoughts?
  9. I'm trying to do the pong. And when I want to collisions, I have the following: game.physics.collide (ball, playerBet, ballHitsBet, null, this); ballHitsBet is a function, but it gives me error then the program does not read my function, provides as follows: Uncaught TypeError: undefined is not a function What can be happening?
  10. instantia

    Map p2 physic

    How to create it? - red line - polygon. - colorful squares - tile map - random or atlas file. How to set the polygon object I know. Here, too, and plan. How do I randomly impose sprites? What to do to create? To trim down the red line
  11. I have a set of pins set up on a board and I want the ball to get a specific velocity when it collides with a pin in order to guide it to a predetermined destination. basically every time the ball collides with a member of the pins group I do a check to see if the ball should be falling left or right and then force that velocity on the ball, this is designed to ensure that the ball falls in the correct predetermined slot. at the moment I'm using the phaser overlap function: this.physics.overlap(coins, pins, moveCoin, null, this); where move coin looks like this: function moveCoin(coin, pin){ if(shouldMoveRight(coin)) coin.body.velocity.x=100; else coin.body.velocity.x=-100;} Now my issue is that this function seems to only work some of the time and not others. This is pretty confusing and I do not quite understand why that would be the case. Is there a better way for me to implement this or is there something i'm doing wrong? I've tried using the collide function as well with the same effect. Some help will be massively appreciated!
  12. Is it possible to have a non rectangular hit box? I found these docs (oddly not from Phaser.io but look identical) which have a setCircle() and setPolygon() method for the Phaser.Physics.Arcade.Body, but the official Phaser docs do not. I see that the Ninja and P2 physics classes have a body element with some methods that look promising, but the rest of my project uses Arcade and there are some vague statements in the docs that make me think that there are some unimplemented features in the library. Can you have mixed physics? Can I implement arcade methods in Ninja or P2 (e.g. moveToObject(), angleToPointer(), etc.) easily? A larger scale question I have; what are the different physics systems for? The docs sort of explain the differences but I'm still unclear.
  13. I read elsewhere on the forum (lessmilk post?) that a good way to horizontally flip sprites was to set the scale to a negative number. When I do that, my sprite falls through the tilemap floor, unlike when the scale is set positive. Here's a link: https://dl.dropboxusercontent.com/u/75126/fallingscale/index.html Any ideas?
  14. I saw the example labeled when particles collide, but it didn't have what I wanted. Let's say that in a game there is a ship and an asteroid. How would I make it so that when the ship hits the asteroid, particles emit from the point of contact, so in this case sparks? Is there a way to check point of contact? And if so, would it need to be in a callback, so when the bodies hit create an emitter? Thanks for any help!
  15. I am trying to create a top-down game with movement constrained to a grid (think Pokemon Red/Blue movement). I have successfully imported a tilemap (32x32 pixel tiles) into my game, and I have set up tile collisions using setCollisionBetween() and physics.collide() for a player-controlled sprite. Currently I am adjusting body.velocity properties on keyboard input to move the player sprite, which works fine but is not really what I want. What I would like to do is to move the player sprite 1 tile (32 pixels) in the appropriate direction so that it always aligns to the tiled grid. I have tried updating the sprite's body.x and body.y values, but when I do this the player sprite seems to ignore all collision logic with the tilemap layer tiles set with setCollisionBetween(). So in short, how can I move a sprite x pixels every key press while still limiting the speed at which the sprite can cover a certain distance (as well as ensuring collisions still work)?
  16. I noticed that generated map using a JSON level scheme (manually created or even generated using Tiled) may cause a problem with collisions. Here is my level file: { "height":16, "layers":[ { "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 28, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40], "height":16, "name":"groundLayer", "opacity":1, "type":"tilelayer", "visible":true, "width":16, "x":0, "y":0 }], "orientation":"orthogonal", "properties": { }, "tileheight":16, "tilesets":[ { "firstgid":1, "image":"https://dl.dropboxusercontent.com/u/18322837/JSFiddle/super_mario.png", "imageheight":64, "imagewidth":176, "margin":0, "name":"tiles", "properties": { }, "spacing":0, "tileheight":16, "tilewidth":16 }], "tilewidth":16, "version":1, "width":16}The collisions seem to work only if I remove the first layer (named skyLayer) from the JSON file. There is something wrong in my code or it is a bug? A live example is available here (to use the level with both layers change ".../level.json" into ".../level2.json" at the line 10). Thanks!
  17. I'm trying to make a little game using physics, where the user pushes balls around. The balls are defined as Sprite extensions, like this: function Player(game, type) { Phaser.Sprite.call(this, game, game.world.randomX, game.world.randomY, 'player') this.anchor.setTo(0.5, 0.5) this.type = type this.body.collideWorldBounds = true this.body.allowRotation = true this.body.bounce.setTo(0.6, 0.6) this.body.setCircle(50) this.body.angularDrag = 50 this.body.drag = 5 game.add.existing(this) } And the interaction is based on doing: this.players.getAt(0).body.velocity.x -= 10with every one of the directions, depending on the key pressed. It works, I can push elements around. But I'm facing an issue, I don't know it it's a bug or it's just expected to work like this and I'm missing something. The problem is that the elements overlap in some situations. For example, if I keep pressing the key, forcing the sprite against another one, it may finally "break" the collision boundary and overlap. Is there a solution for this? Is it a known issue? Thank you
  18. Hi, last time i'm trying to get my head around gaming with HTML5, but i can't really think of a way to do detailed collisions in vanilla Javascript. With detailed i mean (almost) pixel-precice, i absolute don't want objects to get stuck in my games. Does anyone knows a good way to do this? - Jefta Oh and ofcourse i searched on this forums before posting, but surprisingly i didn't find anything about this...
  19. I need to find a way to detect when a sprite exits collisions. My goal here is that when a sprite enters a collision an animation is played and when the sprite exits the collision the animation is paused leaving the sprite at a different frame from a sprite sheet. If there a simple built in function to phaser to achieve this? Or do I need to find a different solution. Here is my simple code so far: function update() { game.physics.collide(cup, sprite2, collisionHandler, null, this);}function collisionHandler (obj1, obj2) { cup.animations.play('fill', 10);}