L
L
lotrop2016-09-12 14:56:44
JavaScript
lotrop, 2016-09-12 14:56:44

Collision detection javascript + canvas 2 objects?

What a good practice to detect collision of 2 objects. Yes, not just detection, but a further shift so that the objects do not enter into each other. That is, so that when they collide, they rest against each other, but do not enter. Are there such techniques? (Checking simply on four sides is not offered).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Korotaev, 2016-09-22
@lotrop

There is a port of the popular Box-2d engine on JS, the interaction of physical bodies based on convex polygons is implemented there. I think it will fit.
And if from zero, then use the acceleration vectors and reset the value on collision.
The object displacement update must be guided by these vectors to calculate the position of the object

N
Nicholas, 2016-09-12
@ACCNCC

Good practice to use the engine! https://html5gameengine.com/tag/webgl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question