#[Solved] Help, this bug is making me go insane

1 messages · Page 1 of 1 (latest)

ancient slate
#

I have a bug, where what the inspector says and what the gameview shows, seem to be completely different entities.

I have a ISystem MovingEntitySystem, which, in update:

  1. If a click was detected, sets the target position on all movable entities
  2. Calls the "move entity towards target" function on all movable entities
    those two are done in 2 separate jobs.

I have 4 entities on screen. But they merge into one pretty fast, because I give them all the same target position every time. The 4 on-screen entities and the 4 inspector entities behave in the same way, always.

All nice and great, but, as per the video, my right clicks don't really do... what's expected. It seems like it EITHER is sent to the entities that are "on screen", or to the entities that are in the inspector. Sometimes, the "entity hierarchy entities" (that I can view and access through the inspector) react to my clicks, but sometimes it's the on-screen entities that I can see.
Clicks seem to be distributed between them randomly. You can see in the video, that sometimes when I click the inspector, the target updates and position starts changing, and sometimes when I click, the entities on screen move, while the ones in the inspector casually complete their own move to their previous destination, and stop moving while the ones on screen are still moving to the next one.
Inputs always seem to go either to the on-screen entities, or the inspector entities, that I can access through entity hierarchy.

All packages are up to date, and I don't have anything weird installed. This is pretty much a fresh project. Freshest unity version, 6000.0.2f1, although 6000.0.0 had the same bug.

Please help. I am going crazy. What could it even be??? Please give me any idea.

#

Oh btw the Y value starts out so high, because all entities go up slowly until I move them for the first time, then they float down to 0.5 (debugging measure), and I already moved the ones on screen once, so they floated down before I started recording, but the ones in the inspector didn't yet, that's why they kept going up
Also, I verified that the same correct target position data reaches both inspector entities and gameview entities. For what it's worth

#

Also, I guess here's my MovingEntitySystem code

    public void OnUpdate(ref SystemState state)
    {
        float dTime = SystemAPI.Time.DeltaTime;
        if (InputCaptureSystem.WasCommandIssued)
        {
            float3 newTarget = InputCaptureSystem.TargetPosition;
            new SetTargetJob
            {
                deltaTime = dTime,
                destination = newTarget
            }.ScheduleParallel();
            InputCaptureSystem.WasCommandIssued = false;
            InputCaptureSystem.PrintDebug("Issuing SetTargetJob to " + InputCaptureSystem.TargetPosition);
        }

        new NavMoveJob
        {
            deltaTime = dTime
        }.ScheduleParallel();

    }
#

and



[BurstCompile]
public partial struct SetTargetJob : IJobEntity
{
    public float deltaTime;
    public float3 destination;

    [BurstCompile]
    void Execute(NavAspect navAspect)
    {
        navAspect.SetDestination(destination);
    }
}


[BurstCompile]
public partial struct NavMoveJob : IJobEntity
{
    public float deltaTime;

    [BurstCompile]
    void Execute(NavAspect navAspect)
    {
        navAspect.MoveTowardsTarget(deltaTime);
    }
}
#

and in NavAspect:


    public void SetDestination(float3 target)
    {
        _navData.ValueRW.target = target;
        _navData.ValueRW.navigateToTarget = true;
    }

    [BurstCompile]
    public void MoveTowardsTarget(float deltaTime)
    {
        if (!_navData.ValueRO.navigateToTarget)
        {
            _localTransform.ValueRW.Position += new float3 (0,1*deltaTime,0);
            return;
        }

        // movement code here, calculates nextPosition no ValueRW calls
        
        _localTransform.ValueRW.Position = nextPosition;

    }
ancient slate
#

[Solved] Help, this bug is making me go insane