- Home /
My Player is crossing the ground through air
Hello, player is going over the ground as you can see in the video below. I want to make that the player can move only on the ground. Im using raycast and moveTowards for movement right now. thank you in advance for your help
problem here: https://youtu.be/1U423hWNbJo script here: http://prntscr.com/dsk14h
Answer by GrayMatterTutorials · Jan 09, 2017 at 08:09 AM
Alright! @zankor, you need a waypoint system! What you are going to do is basically set up a connection with every single grid cell you have. Say you start at a grid cell and want to get to a grid cell on the other side of the map. You will set that other grid cell as your destination and ask the controller script for a path that gets you there. It will take your current position, check the nearby grid cells, and if they move closer to the object, they add themselves to the path. This continues until you reach the destination. Then the controller sends you a list of waypoints (grid cells) you have to travel across before you get to the destination. That will ensure they stay on the ground. My suggestion, look up the A* Pathfinding Design Pattern. This will give you an in-depth overview of creating a smart AI to transverse this type of terrain. Here's a good video describing it: https://www.youtube.com/watch?v=-L-WgKMFuhE. Best of luck to you! If you have anymore questions, feel free to comment.
It's no problem, that's what we are here for! If you have any further questions related to this, feel free to comment below and I will help you out as much as I can. If you have any new questions that are completely unrelated from this, start a new question, I'll keep my eye out!
Your answer
Follow this Question
Related Questions
Push an object opposite direction of mouse position 0 Answers
Move player between 3 given points only by touching on the left/right side of the screen 1 Answer
AI behaviour in 3D game, general help needed 2 Answers
how to stop something from following in the y axis 1 Answer
Using MoveTowards on button click 0 Answers