Okay, I have the homing missile implemented. It will follow the player, but I want it to avoid the walls. I tried out A* but I want to make my own. I need some help plzz.

Screen Shot of my Game

  • \$\begingroup\$ You can also look into "local avoidance". \$\endgroup\$ – Foxwarrior Apr 13 at 21:49
  • \$\begingroup\$ What unwanted behavior did you observe from using the industry-standard A* algorithm, that you want to improve upon with your own version? We need to clearly understand what needs to be different about solutions we offer here. \$\endgroup\$ – DMGregory Apr 13 at 23:50

fo me, I am using raycast to create nodes and then use a* algorithm to calculate path. But I am just create some iteration of path since game environment will changed every frame. Here's how I create nodes:

  1. cast a ray (Physics.raycast) from missile to target, if there's a obstacle get hit point of raycast (usually it's a return value of raycast method).
  2. add missile pos & hitpoint pos divide by 3/4 or 4/8 or whatever it's up to u.
  3. we got a node by execute step 2.
  4. we can repeat step 1 & 2 but this time, we start from the node and we cast some degree to the left or right (the degree is up to u). 5.let's said you cast to the left first, since this cast is not to target, just decide how long you want to cast. 6.same as step 1 & 2. but this time we not cast a ray anymore, just switch it to right direction from first node we've got from step 3. and do the same thing as left in step 5.

  5. now you have 3 nodes! now all you have to do is compare the last two nodes (left & right) because they are branched from the first node, compare who is closest to the target. 8.let's said the result of comparison between left and right nodes is second nodes

  6. now missile will move to first node and then second nodes

important to note: 1. as this method is not generate path nodes from start to end, missile can't arrive to the target if they reach dead end like maze environment. But I like this method because it's like realistic missile and low cost performance. 2. you can improve it by increase branch nodes per turn.

| improve this answer | |

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.