[DEMO] How to detect slopes in a platform game using the Dot Product: Godot tutorial
This demo shows how to use the dot product to detect the angle of a slope in a platform game. It's made with the Godot game engine.
Make Professional 2d Games (Kickstarter): https://gdquest.mavenseed.com/courses
----
Download the project: https://github.com/GDQuest/Godot-engine-tutorial-demos
It's in the 2017/final/10-Slope with dot product folder
(you can use https://minhaskamal.github.io/DownGit to download folders from github as ZIP files)
This is another common use of the dot product: detecting slopes in platform games. In the previous series, the character could only walk on the ground. Slopes are trickier: you need to detect its exact angle to know if the player can walk on it or not.
Our only way to know this is to use the collision normal. Meaning that we need to a collision to happen. And to get a collision, we need the character to move first. That’s why the code can be a bit tricky: we first move the character, check if we’re on a slope or not. If we are, we revert the motion, clean up the move vector, and move the character again. This is what the demo shows.
Daily tutorials series! 21/30
The playlist: https://youtube.com/playlist?list=PLhqJJNjsQ7KEr_YlibZ3SBuzfw9xwGduK
Project sources on Github: https://github.com/GDQuest/Godot-30-days-tutorial-challenge-2017
This tutorial is supported by:
- Gamblify: https://www.gamblify.com/
- Pineapple Works: http://pineapple.works/
Subscribe to the channel now and become a member of the community! https://youtube.com/c/Gdquest?sub_confirmation=1
Follow GDQuest on:
Twitter: https://twitter.com/NathanGDquest
This video is licensed under the CC-By 4.0 license: https://creativecommons.org/licenses/by/4.0/
You can attribute it to "GDQuest and contributors - https://www.gdquest.com/"