Jump to content

Simple Path Finding Problem


Recommended Posts

Hi,

I want to create a simple effect where small spheres move along the edges of a grid. They move from one vertex to the other, and can only change direction when they've reached a vertex. They also shouldn't double back to the vertex they just originated from, but they are allowed to visit a vertex more then once.

I don't really care if the spheres collide with each other, as I'm only going to use a few and will change the random seed so that they don't appear to collide in camera view.

I'm stuck on how to do this. My thought was to create a attribute for each vertex, and then use a ForEach to assign a vertex order for the path of a single sphere (only of vertexes it would follow), then delete the other vertexes it didn't arrive at. I would then use the Sort SOP to put everything in the right order, and then use the Path Follow.

Seemed like a good idea at the time, but I couldn't get it work.

This really seems like a POP problem to me, but I have no idea how to get started on it. Anyone have any tips on doing something like this?

Link to comment
Share on other sites

yea, I'm surprised Macha hasn't replied. I would have thought he'd find this problem interesting ;)

I did come up with something using POPs, but my approach was very simple. I basically redirect particles LEFT or RIGHT at regular intervals, but adjusting the timing I can make it look like they are following the edges on a grid.

While this approach works fine for a square grid pattern, an object made up of irregular edge lengths wouldn't work. I'll run some more tests with what I have and see if a square grid pattern gives me the effect I'm going for.

I'm sharing the HIP file if anyone is interested.

My next step is to apply a gradient to the lines so they look more like paths of energy.

setup-path-finding.hip

Link to comment
Share on other sites

yea, I'm surprised Macha hasn't replied. I would have thought he'd find this problem interesting

Ah, well that's because Macha is a little busy recently and his home laptop doesn't like Houdini.

If I was to do this I'd perhaps get those points into Python and search through paths there by selecting from nearest neighbors. You add each step into a list and then at the end you use the list to reconstruct a curve from it and use that to animate.

There are some libraries out there that do this automatically and very efficiently but I can't remember what its called.

Recently though I have seen ways to do such things with matrices, and it is very clever and interesting but I haven't really had the opprtunity to play with it. If we could use arbritrary n*m matrices in vex then that would be great. In the meantime I think numpy is the best choice for that.

Edited by Macha
Link to comment
Share on other sites

I'm actually getting ready to work on a pathfinding AI for a strategy game that I'm working on with some friends. Should turn out pretty good. I will star this thread and I will share what I can of the code with you if you like. It is going to work similarly to what you are looking for, but I think it will end up being in JS. Not sure how portable that is to Python.

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

×
×
  • Create New...