newknight Posted November 26, 2016 Share Posted November 26, 2016 Hello all, I have a problem with Phaser P2 physics in short i have 2 groups with objects. One is for my projectiles and the other is for enemies. The problem is that i want when projectile hits an enemy, the enemy should not move (it bounce back a little...). This is the code for my enemies i set the body.kinematic = true but it doesn't work. Thanks. this.enemiesGroup = this.add.group(); this.enemiesGroup.enableBody = true; for(var i = 0; i < 3; i++){ for(var j = 0; j < 9; j++){ var tmp = this.enemiesGroup.create( 80 +(j*66), y , 'enemies_1'); this.physics.p2.enable(tmp, this.Debug); tmp.enableBody = true; tmp.physicsBodyType = Phaser.Physics.P2JS; tmp.name = 'enemy' + buff; this.enemiesHP[tmp.name] = 100; tmp.anchor.setTo(0.3); tmp.angle = 90; tmp.scale.setTo(0.6); tmp.body.setCircle(18); tmp.body.kinematic = true; tmp.checkWorldBounds = true; var exp = this.enemyExplosion.create(0, 0, 'explosion'); exp.visible = false; exp.exists = false; exp.anchor.setTo(0.5); buff++; } y = y + 90; } Quote Link to comment Share on other sites More sharing options...
The_dude8080 Posted November 27, 2016 Share Posted November 27, 2016 shouldn't you use "body.static = true" if you dont want it to move? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.