Jump to content

JavaScript 2D collision and pushing other objects not working correctly


Oasisx
 Share

Recommended Posts

Hello, hope you'll are doing fine. I'm a beginner programmer and recently I've been working on a 2d physics game engine in JavaScript. Everything seemed to be working fine until I have come across an annoying bug in my push mechanic.

I have created a 2d collision system where object A will be pushed away b object B, etc. In addition, I have created a push mechanic meaning, object A can push object b (if it’s not solid). However, I have come upon a problem where e.g. object A (Player), object B (box which the player can push) and object C (Solid wall), he problem occurs when object a pushes object b against object, what happens is object B gets pushed away by object A, but object A doesn’t get pushed away by B meaning, object A will get inside of object B and it will push the object to the top instead of pushing it to the left by activating the wrong collision detection. (as seen in the video).

Video which shows the problem: https://www.youtube.com/watch?v=8DHKJNOrO54

(Project files below)

I've been trying to solve this problem for awhile now and I just can't find the perfect solution. 

If anyone would be able to help it'd be great. Thank you

 

game_v1.zip

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...