Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
SamedTarik

SetDestination and CalculatePath's Path Status Check Works Too Late

Question

Hi all, I'm trying to make a turret defence game. And i'm trying to check if my navmesh agent can reach to target if i place the turret on selected grid by using bool return of SetDestination. The problem is, it reports that path is blocked when i try to place another turret after i placed the turret actually blocking path. Below is my placement function of turret placement script.

Edit: I tried with both SetDestination and CalculatePath. Nothing changed, below is the one i tried with CalculatePath.

 

Edit2: Corrected syntax.

Thanks in advance.
 

Please login or register to see this code. Edited by SamedTarik

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Never used calcpath but for me it seems that your calcpath is wrong

Please login or register to see this link.

  • Like 1

Share this post


Link to post
Share on other sites

  • 0
Please login or register to see this quote.

 

Edit: Ah true, i forgot to update the code. That syntax is wrong you were right. But the problem still continues with right syntax.

 

No it's working, the problem is, it's working too late. The script below solved the problem temporarily, but i don't want a solution like this actually.

Please login or register to see this code. Edited by SamedTarik

Share this post


Link to post
Share on other sites
  • 0

So when there is only one turret all works? when you add another turret behind the first one it says path is blocked? are turrets using the obstacle navmesh or what was the component to add dynamic nav objects called?

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

It works like a charm until there is one spot left to block path. When I add the turret that actually blocks the path, nothing happens (for the first code, not the second one). But after the path is blocked, it says path is blocked and not allows me to place turrets. I want it to say that and prevent me when i'm trying to place the turret that blocks path, not after i placed it.

Share this post


Link to post
Share on other sites
  • 0

Are these turrets those what are shooting the enemies or turrets are those moving enemies what are walking on the road?

Picture would help to get better idea but if you are placing them in map with mouse in any place you want then you could spawn it to mouse position and check the path on this part. If path is good allow spawn else no...

Im probably not getting how the game works so pics please

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Turrets (all of them have navMeshObstacle) are stationary and shooting moving enemies. At first, there is no turret on map, player places them on runtime. And moving enemies (all of them have navMeshAgent) spawn at a certain point and try to reach the goal, it's a classical tower defense game actually. I will upload a picture soon but not sure if a picture can explain the situation since the error happens in a time period.

Edited by SamedTarik

Share this post


Link to post
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.

Guest
Answer this question...

×   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...