+ 7

Javascript Collision

So i am making an infinite jumper game and i was wondering how i should make a collisiob system. Made in js without collision btw. I have a few ideas but i want to know what you think :) https://code.sololearn.com/WlO7yaq53vov/?ref=app

17th Nov 2018, 11:50 PM
Emperor Bob
Emperor Bob - avatar
4 ответов
+ 5
Check if the x of the player is greater than the x of the obstacle.
18th Nov 2018, 3:21 AM
Rowsej
Rowsej - avatar
+ 5
Thanks guys i'll be sure to try them out :D
18th Nov 2018, 5:56 PM
Emperor Bob
Emperor Bob - avatar
+ 4
Quick detail about the code: its gonna be like a template so you can easily change the characters
17th Nov 2018, 11:51 PM
Emperor Bob
Emperor Bob - avatar
+ 3
so, you must check on destination between two objects and it will be: destination = radius1 + radius2 then, if(positionObject1.x - positionObject2.x <= destination) vectorObject1.x = - vectorObject1.x vectorObject2.x = - vectorObject2.x
18th Nov 2018, 12:24 AM
_yaroslavv [online_everyday]
_yaroslavv [online_everyday] - avatar