Search the Community
Showing results for tags 'no collision'.
-
Hello, it is me again. I have a tileset(16x16 each square) I made a tiled map with it and exported as .json After importing it into Phaser game it works fine, collision works... But when I scale the layer by two, the collision is not working(Debugging the layer shows tile body) Please help me! Also, I am not sure how the values should be in - map.setCollisionBetween(n,m); The code for that: //This goes into create function map = this.game.add.tilemap('map'); map.addTilesetImage('tiles'); map.setCollisionBetween(1, 400); layer = map.createLayer('normal'); layer.scale.set(2); layer.resizeWorld(); this.sprite = myGame.game.add.sprite(200,400,"player"); this.sprite.smoothed=false; this.sprite.scale.setTo(2); this.game.physics.enable(this.sprite); this.game.physics.arcade.gravity.y = 200; //This goes into update function this.game.physics.arcade.collide(this.sprite, layer);
- 1 reply
-
- no collision
- scaling
-
(and 2 more)
Tagged with:
-
Hi! I'm new to this so this is probably a dumb question.. Been trying to make a game where object moves through labyrinth without going through walls. I implemented collision detection to the point where I'm sure its working but when I tried to move it with .position method there was no collision happening so I ended up using the moveWithCollisions method. This works but once you press the button the object starts moving and doesn't ever stop it just changes direction at another key press. It also increases speed and both of this thing make it very useful to move it through gaps in the walls and navigate it.. So is there a way to control speed and stop mesh before there is a collision/intersection? Or is there a whole different better way to implement movement of that kind? Any advice, opinion and info welcome and thanks so much This is how code for one key press looks like: (sphere is the object we're trying to move - i have yet to import it but at least I know how to do that) window.addEventListener("keydown", function(evt) { if (evt.keyCode==87){//forward scene.registerBeforeRender(function () { sphere.computeWorldMatrix(true); //labyrinth.computeWorldMatrix(true); if (!sphere.intersectsMesh(labyrinth, true)) { //sphere.applyImpulse(new BABYLON.Vector3(premikanjeX, 0, premikanjeZ), sphere.position); var forward = new BABYLON.Vector3(parseFloat(Math.sin(parseFloat(sphere.rotation.y))) / 8, 0, parseFloat(Math.cos(parseFloat(sphere.rotation.y))) / 8); sphere.moveWithCollisions(forward); } });}}, false);
- 19 replies