Jump to content

[Phaser 1.1.6] Immovable sprites moves - Collision issue


Mefteg
 Share

Recommended Posts

Hello,

 

I have a problem with sprites with a body set as immovable.

When my player collide with two immovable bodies, one of these bodies moves.

 

You can try with the two bushes under the player.

1- Go on top of the left bush and collide with it
2- While still colliding, try pushing the right bush

 

http://folia-game.herokuapp.com/index-dev.html

 

The code for the player and the bush are easely readable with DevTools (player.js and bush.js, you can read obstaclesgroup.js too).

 

I don't understand what I'm doing wrong so if someone can help me to fix it, I'll owe him one.

 

Thank you.

Link to comment
Share on other sites

I had a similar issue, I had the player, obstacles and enemies the player and enemies had to have immovable=false and obstacles  had to be immovable=true otherwise the obstacles would just be pushed around, but this caused a problem with the enemies and the player, they wouldn't collide so What I done was checked the distance between the player and all the enemies if the distance between them = (enemy.width+player.width)/2 then the enemy stops moving or whatever I wanted to happen.

 

I had a quick look trough your code but I couldn't find where you set the immovable property on the obstacles or player

 

Game looks pretty cool BTW

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...