Тёмный

5. COLLISION DETECTION // Coding a Minecraft Clone with JavaScript + Three.js 

Dan Greenheck
Подписаться 3,4 тыс.
Просмотров 2,5 тыс.
50% 1

Learn how to create a Minecraft clone from scratch in this 10-part video series. I’ll show how you can create a procedurally generated voxel world with collision detection, terraforming and more!
❤️Like this content? Support me on Patreon: / dangreenheck
🕹️ DEMO: dgreenheck.github.io/minecraf...
⭐️ GITHUB: github.com/dgreenheck/minecra...
0:00 Intro
1:03 Physics Class
2:12 Collision Detection Phases
3:02 Hooking up Physics
3:36 Broad Phase
7:16 Collision Helpers
13:48 Narrow Phase
28:42 Contact Point Helpers
30:25 Resolving Collisions
33:27 Gravity
35:45 Adjusting Player Velocity
39:38 Jumping
41:30 Fixed Time Step
45:34 Bug Fixes
46:52 Outro

Наука

Опубликовано:

 

22 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 41   
@dangreenheck
@dangreenheck 8 месяцев назад
Have you tried writing your own collision detection code before, or have you always used a library?
@abdelrahmanassem5606
@abdelrahmanassem5606 8 месяцев назад
Haha unfortunately library
@matteomicari9559
@matteomicari9559 8 месяцев назад
Rapier, spent about two days screaming at a screen to make collision for custom 3d models
@abdelrahmanassem5606
@abdelrahmanassem5606 8 месяцев назад
lol me too@@matteomicari9559
@dangreenheck
@dangreenheck 8 месяцев назад
I feel you! I tried getting Cannon.js working first and threw my hands up after a few hours. I’m sure I could have gotten it working eventually, but I had more fun writing this!
@genshian
@genshian 8 месяцев назад
The crazy thing is I was trying to do this yesterday using react three rapier. The issue is creating your custom hooks are impossible without going into some of the principles you shared here. Excited to continue watching your videos! I understand their some what niche and that's why Im so grateful of you sharing this to the community.
@brambekkers
@brambekkers 6 месяцев назад
I usually don't comment on videos but I'll make an exception with this one. I am very impressed with your tutorial. I really appreciate the detailed explanation, quality of the video and balanced pace of the tutorial. I am very thankful! Keep up the good work!
@dangreenheck
@dangreenheck 6 месяцев назад
Thank you very much! I appreciate the kind words.
@lucasnicolasbuttarelli9216
@lucasnicolasbuttarelli9216 6 месяцев назад
Holuuuu, no puedo esperar mas la parte 3. Saludos!!
@marekrybakiewicz370
@marekrybakiewicz370 8 месяцев назад
wow, finally a tutorial i want to follow! awesome job
@608_diesel
@608_diesel 7 месяцев назад
Brilliant work! Thank you so much for sharing and breaking it down, makes me wish I would have paid more attention in math when I was in school haha.
@gazehound
@gazehound 8 месяцев назад
New favorite RU-vid series...
@KskskdodOdkrjen
@KskskdodOdkrjen 6 месяцев назад
Waiting for part six!😸
@dangreenheck
@dangreenheck 6 месяцев назад
Should be coming next month...
@vinaciotm
@vinaciotm 7 месяцев назад
so cool. Thanks, keep doing
@ankurbhardwaj04
@ankurbhardwaj04 5 месяцев назад
We are waiting for more videos of this series
@dangreenheck
@dangreenheck 5 месяцев назад
I’ll be releasing the next video in this series in the next week or two.
@teturd169
@teturd169 5 месяцев назад
@@dangreenheck plz do ur great at explaining stuff and not just showing code
@xderen_xd
@xderen_xd 6 месяцев назад
God may bless you, please continue or I will continue programming my own minecraft because this is insane is the first project tutorial where you make a real game with all their futures almost like you build your own game-voxel engine hahaha
@dangreenheck
@dangreenheck 6 месяцев назад
Don’t worry, I definitely plan on finishing it! I haven’t had much time to make videos due to the holidays, but plan on recording the rest of the videos in the next few months.
@nerex_rsmusic8344
@nerex_rsmusic8344 6 месяцев назад
Jah bless, with this you have everything to do your own, you have physics, the world, the resources, optimization. I am in a position where I didn't do this part since I was hopping to watch more uploads but in other hand you can study the github but the most great thing is that you Master, teached so well this topic that I feel like with the same logic I can do stuff as for example recolection
@dangreenheck
@dangreenheck 6 месяцев назад
Thank you! I will be uploading the rest of the videos in this series over the next month or two.
@nerex_rsmusic8344
@nerex_rsmusic8344 6 месяцев назад
@@dangreenheck Thank you too! I will be noticing your uploads then, keep going your channel is unique and really helpful :)
@prashlovessamosa
@prashlovessamosa 8 месяцев назад
Great stuff glad I found you.
@dangreenheck
@dangreenheck 7 месяцев назад
Thanks and welcome!
@genshian
@genshian 8 месяцев назад
Epic!!
@SantaGrapa
@SantaGrapa 4 месяца назад
Looks awesome. Im trying to recreate it in c#, unity but im getting a few errors idk if anyone can help me out with this. First, if gravity is big enough, xz overlap becomes less than yOverlap and kind of pushes player to the center of the block. Second, when walking close to a wall, block corners push player a bit along their normal, which makes walking while facing a wall clunky . Probably its some mistake translating from js to c# or maybe i skipped a few lines of code? Been 2 days and still trying to figure it out.
@dangreenheck
@dangreenheck 4 месяца назад
1. If you increase gravity, you'll likely need to increase the physics simulation rate. Higher forces/speeds require faster simulation rates since objects are moving a large distance between each frame. 2. The jerky motion while walking next to walls is not present in the JavaScript version, so it is something with your implementation. First, make sure you are running physics at a fixed rate or you'll get very strange behavior. Second, you need to re-check all other collision points each time you resolve a collision (i.e. update player position), since the player may no longer be colliding with that point. This is likely your issue. See this line in the source code: github.com/dgreenheck/minecraft-threejs-clone/blob/07a50a5ee3e390de334f467c6a4f553dd564f636/scripts/physics.js#L171
@KskskdodOdkrjen
@KskskdodOdkrjen 4 месяца назад
This series is amazing but i'm stuck at the applyEuler thing, I learnt a lot of things in this series but I can't understand this one.
@dangreenheck
@dangreenheck 4 месяца назад
Understandable, vector transformations and coordinate frames can be confusing! I didn’t explain it great either. There are two coordinate frames: the world and the player. The world coordinate frame is the “reference” frame that never moves. The player coordinate frame is centered on the player, with one axis always pointing where the player is looking, the other pointing up, and the other is to the side of the player. This player frame moves relative to the world frame. When the player moves forward, the user is applying a velocity along the forward axis of the player. We need to convert this to world coordinates so we know which direction to move the player in the world frame. So if the player has a velocity of 5 m/s along its forward axis and the player is pointing East, applyEuler will rotate the vector 90 degrees clockwise, so the world velocity will be 5 m/s to the East and we can move the player in that direction. It’s hard to explain without pictures but I hope that clarified it somewhat.
@GaboomMixes
@GaboomMixes 4 месяца назад
@coffeecodecreate 12:53 I have run into an issue where when I go into a block it turns solid red and not kind of red and then it just stays there and doesn't disappear. What is the issue? Could you help me? Thanks!!
@dangreenheck
@dangreenheck 4 месяца назад
Make sure you are clearing the collision helpers each frame. Otherwise they will persist forever.
@GaboomMixes
@GaboomMixes 4 месяца назад
​@@dangreenheck Thank you so much!!
@naveed_snr
@naveed_snr Месяц назад
I'm working on an fpp college tour project and want to add collision detection to it. Since I didn't use any loops to generate the world and used a 3D model instead, I'm having a hard time following along. Can I get some help?
@dangreenheck
@dangreenheck Месяц назад
You will need to use a 3rd party physics library like Rapier.
@naveed_snr
@naveed_snr Месяц назад
@@dangreenheck I tried using rapier and it was kinda overwhelming. I followed the documentation but couldn't get collision detection to work. I couldn't find many relatable tutorials on RU-vid either. I also tried enable3d and physijs as I heard them being a bit easy to use but they are not completely documented yet. Can you make a tutorial about adding physics with rapier (most tutorials are about adding physics to basic shapes like cube, capsule etc. and not imported 3D models). I would highly appreciate any help.
@niuage
@niuage 6 месяцев назад
Did you use AI to create your thumbnail? Looks pretty damn good but usually AI has issues with minecraft-like terrain, from my very small experience with it.
@dangreenheck
@dangreenheck 6 месяцев назад
Indeed I did! DALL-E has come a long ways.
@niuage
@niuage 6 месяцев назад
@@dangreenheck DALL-E 2 or 3?
Далее
I Melted Wood With Friction
8:44
Просмотров 806 тыс.
Procedural Voronoi Explained
9:57
Просмотров 9 тыс.
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 695 тыс.
It's Not Nostalgia. Old Minecraft WAS Great.
22:31
Просмотров 1,5 млн
I Made Minecraft RTX Actually Realistic in Blender
5:21
Красиво, но телефон жаль
0:32
Просмотров 1,4 млн