Jump to content

Controlling the player to pathfind?


dylanpdx

Recommended Posts

I haven't watched the video, so merely speculating.

 

Also, it generally helps people if you post what you have tried.

 

My proposed method:

Tickhandler.  Call the pathfinder for the player to get a path.  Every tick use your tickhandler to call the player-navigator to move him along said path.

 

It might be easier than that... you -might- be able to just set him a path and let him go (as he shares most of the code with EntityLiving/etc).  But I'm guessing because of the player-controlled aspect you will have some additional handling to do (i.e. through the tick-handler).

Link to comment
Share on other sites

Okay, so, to do this, you would probably need a pretty good understanding of the concept of pathfinding and how it works, How well do you know A-Star, DFS (Depth-First Search), or BFS (Breadth-First Search)?

 

Here is a good source to help you decide which is best suited for what you require.

 

I would say that the pathfinding bit is the difficult bit, once you have a path for the player, all you need is a way to make the player move. As mentioned above by shadowmage4513, EntityPlayer does share a lot of code with EntityLivingBase, so you could override some code in there, or (what I would do) have a fake key presser for the player, so it simulates 'w' 'a' 's' 'd' or 'space' which may be more efficient than making the player move like a mob.

 

Hope this helped.

 

Here are some good sources for the three algorithms:

A-Star in games

Introduction to A-Star

DFS

BFS

 

I would recoment using A-Star, but the other two should also work.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.