question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nav: Add NavStop component

See original GitHub issue

Hi @reeseschultz ,

I tweeted you just the other day regarding issues I’m having stopping an agent. Thought I’d start a discussion on here as it will be easier! So, in my project, I’m creating a couple of different component data structs to handle agent actions. For example:

public struct NavGoTo : IComponentData
{
     public float3 Location;
}

public struct NavStop : IComponentData
{
     // nothing here
}

public struct NavWander : IComponentData
{
     // nothing here
}

Then in my movement system I have

     // Handle NavWander
            Entities
                .WithAll<NavWander>()
                .WithNone<NavHasProblem, NavNeedsDestination, NavStop>()
                .WithReadOnly(renderBoundsFromEntity)
                .WithNativeDisableParallelForRestriction(randomArray)
                .ForEach((Entity entity, int entityInQueryIndex, int nativeThreadIndex, in Parent surface) =>
                {
                    if (
                        surface.Value.Equals(Entity.Null)
                    ) return;

                    var random = randomArray[nativeThreadIndex];
                    commandBuffer.AddComponent(entityInQueryIndex, entity, new NavNeedsDestination
                    {
                        Destination = NavTools.GetRandomPointInBounds(
                            ref random,
                            renderBoundsFromEntity[surface.Value].Value
                        )
                    });

                    randomArray[nativeThreadIndex] = random;
                })
                .WithName("NavWanderSystem")
                .ScheduleParallel();

            ... 
            
            // Handle NavStop 
            Entities
                .WithNone<NavHasProblem, NavWander>()
                .WithReadOnly(translationFromEntity)
                .WithNativeDisableParallelForRestriction(translationFromEntity)
                .ForEach((Entity entity, int entityInQueryIndex, in NavStop navStop) =>
                {
                    commandBuffer.RemoveComponent<NavStop>(entityInQueryIndex, entity);
                    commandBuffer.AddComponent(entityInQueryIndex, entity, new NavNeedsDestination
                    {
                        Destination = translationFromEntity[entity].Value
                    });
                    Debug.Log($"Stop entity ${entity.Index}");
                }).WithoutBurst()
                .WithName("NavStopSystem")
                .ScheduleParallel();

            Barrier.AddJobHandleForProducer(Dependency);

Ok, so this works - sometimes! Everytime I add a NavStop the system correctly picks this up and I see the DebugLog. However, the agent doesn’t always stop. I’ve tried quite a few different things (been at this simple stop functionality for about 4 days! lol) and while I’m new to ECS, I can’t for the life of me figure out why what I’m doing shouldn’t work… the fact it sometimes works makes it even more frustrating. I’m wondering if it could be something to do with the way NavNeedsDestination works and so my next step was to ask you for some advice. Can you think of any reason why setting the Destination to the entities Translation won’t work?

Just to note, I’ve also used the Translation in the ForEach lambda rather using var translationFromEntity = GetComponentDataFromEntity<Translation>(true); but get the same result.

Any thoughts? Would really appreciate any insight you might have.

Thanks

Edit: Maybe it’s because I’m using .ScheduleParallel() and they are conflicting? It appears as though .Schedule improves things slightly but there is still and issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
reeseschultzcommented, Jan 15, 2021

@P-Stringer I added NavStop, which is part of Nav v0.15.0. You can view the changes in this commit. It should work. I tested it in the NavHybridDemo by making the agent stop when Tab is pressed (sometimes the agent’s animation freezes—that’s a separate, scene-specific issue). Anyway, I really appreciate that you brought this up, and also that you tried to apply a workaround and shared the code for what you did (most people don’t). I was able to knock this out this morning since I don’t have much time later today.

Be aware that the feat/demo-overhaul has not been synced with master, meaning it’s missing later changes that that were added to master. Like I said, I’ll try to sync them, but it’ll be at least a week before I can do that. There’s no NavFollow component in that branch (yet!), but the underlying code should now be ready to support it, is what I mean. I know it should be about ready because the new “Stranded” demo supports click-and-drag movement.

0reactions
reeseschultzcommented, Jan 16, 2021

Glad it helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Microsoft Dynamics NAV
This article explains different Setup configuration options for installing individual components on Microsoft Dynamics NAV.
Read more >
Create or Load Setup Configuration File - Dynamics NAV
In the Choose an installation option page, choose Load Configuration. This option is located under Custom Components. In the Open dialog box, ...
Read more >
How to create a new Web client for Microsoft Dynamics NAV
Run the Microsoft Dynamics NAV setup file. Click on Add or remove components.Click on the drop down for Web Server Components and select...
Read more >
Dynamics NAV Development for Non-Developers: Part 6
1) In the Development Environment (Object Designer), find and “Design” the page which requires the new field(s) [see previous blog for more ...
Read more >
V8V Nav - stop screen from opening
Aston Martin - V8V Nav - stop screen from opening - I just bought a 2006 V8 ... I read the owners manual,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found