0
\$\begingroup\$

I'm struggling to make the sprites avoid each other and other obstacles in the field. To achieve something like this:

enter image description here

To do so I decided to have a 3D environment with an Orthographic camera. It all looks as I wanted.

I have set up a plane. My sprites have a 3dCollider and a rigidbody as I want them to be affected by physics.

enter image description here

I move the sprites using RigidBody.MovePosition.

I checked the collisions, how far they where from their target position, etc...

I've tried also a few scripts that intend to do something like this, but I think they are not suitable from what I am doing as after adapting them they don't work.

Can somebody give me some guidance on a simple way to do this? I don't want to use a A* pathfinding system as I think it's too complex to what I want to do, but if I have to use one I will... I just need some guidance on this...

\$\endgroup\$
  • \$\begingroup\$ RCTN uses a naïve solution. It sends troops in a direction, makes them collide and hope for the best \$\endgroup\$ – Bálint Feb 25 '17 at 14:00
  • \$\begingroup\$ Without telling us what "a few scripts" are that you've tried, or in what specific way "they don't work," it's hard for us to diagnose what implementation issue you're experiencing. Try adding more detail to your question about the results you have so far and what specifically you want to improve/fix. (As an aside, I'm not sure why people get so wary about A*. It's one of the simplest and best-performing pathfinding algorithms known, and is extremely well-studied. What you're trying to do (avoiding moving obstacles) is in fact substantially MORE complex than what A* solves) \$\endgroup\$ – DMGregory Feb 25 '17 at 15:45
-1
\$\begingroup\$

Change your sprites to use a capsule collider. They should allow for enough spacing to get the effect that you're looking for and also make sure that they can't run through each other. You will have to fiddle around with the capsules radius to get the spacing right but after that you should be good to go.

You might have to look into squad movement techniques if you want your units to move as a group without having them all try to go into a specific point. This often looks very messy since they all try to run at the same spot without giving which makes them run around to get a better position.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.