Possible event bug?



  • Yes! That's it.
    Sometimes objects are placed somewhere between two waypoints but yeah. Each object always moves towards next available waypoint on path.

    Thank you.



  • I was able to find the cause of this. The issue is with adding events while moveToPath is true and the object is not on the path, but moving to it.

    The reason this causes issues is because the 'moveToPath' behavior is actually a separate tween. While moving to the path using moveToPath, the actual tween on the path is not initialized. So when adding events right at game launch, you are basically adding events to the 'moveToPath' tween. Upon reaching the path, DOTween notices that the previous events were not fired and tries to catch up by firing all of them at once.

    A quick workaround for this is to add events when moveToPath is false, i.e. the object is moving on the target path. More callbacks will be added soon to make this easier.



  • Oh.. I was expecting an actual fix/update because it is a bug but okay no problem!

    You mean after creating path with moveToPath set to true and have started moving objects by .StartMove, set moveToPath to false right before setting events?
    I just tried that but that didn't help.

    public void MoveTrain(List<WorldTile> wts)
        {
            savedTileData = wts;
    
            for (int i = 0; i < cars.Count; i++)
            {
                GameObject car = cars[i];
    
                sms[i] = car.GetComponent<splineMove>();
                sms[i].moveToPath = true;
                sms[i].pathContainer = pm;
                sms[i].speed = 0.5f;
                sms[i].startPoint = StartPointManager(i);
                sms[i].StartMove();
                sms[i].moveToPath = false;
            }
            EventSetter(wts);
        }
    

    Thanks



  • No, moveToPath is true as long as your object is moving to the path. You can set events when the object reached the path (when moveToPath is false). You do not modify moveToPath for that purpose.

    Regarding a fix: we do not store events somewhere, they are applied to the current tween immediately. So if you are moving to the path, events are used for that tween - which is the wrong one, in your case. Maybe some other developer would like to use events on that moveToPath tween instead. Since the behavior was only reported once, the above workaround still allows both options.



  • Sorry I just saw this reply.

    I really don't know what you're saying at all... help me understand please.
    So I've started moving objects with their events set accordingly. And then what?

    You can set events when the object reached the path (when moveToPath is false)

    Um the set of objects is on path already even before they start moving. Let me show you a screenshot -
    alt text

    Just to clarify, events need to be set before they reach their next points so that the logic in the callback would perform. Because all callbacks for previous points are called all at once when they hit their first points, all calculations in the callback method gets messed up.



  • Please see this image.
    https://www.autodraw.com/share/TQHTF4EAW06Z

    • You are setting events while the object is moving to the path. This does not work.
    • You can only set events when the object is on the path (see red text in image).

    Your options are
    -> disable moveToPath, then the object will initialize the path tween immediately, and you can set events.
    -> or, wait until the object has reached the path, then set events.
    -> or, do not use events at all. But add colliders on each waypoints which will trigger your custom methods (see events example scene, there is a sample for colliders too).

    Hope this clears it up. I will look into how to add events for the "Path Tween" when moving on the "moveToPath Tween" at a later point.



  • Ah ok so I just CANNOT. In your previous reply you mentioned "workaround" but that was misleading. None of the options works for me as I must use moveToPath before objects reach the path and this happens over 500 hundreds of times during game. This is crucial for my game as I constantly create new path over and over for multiple objects.

    I also want to avoid creating and destroying a bunch of colliders over and over as that affects the performance..

    All events from previous points being called all at once with the use of moveToPath is clearly a bug. That should not happen as those points aren't even being touched.

    Also, you say I can set events when objects are on the path but that is not true. I have tested this hundreds of times.
    I have a set of objects and some of them are away from the path, some others are actually on the path before they start moving. The ones that already were on the path before moving/setting events also trigger all events from previous points when they hit their first point.

    I understand this isn't your priority because so far no one else seems to need this fixed but let me know when you feel like fixing it. Thanks.



  • Also, is this happening because there's something wrong with DOTween or is it just SWS?



  • Watch your language. I do not "feel like" replying to this thread anymore with your passive aggressive tone. There is a workaround and I have stated it numerous times above and also in the image. I did say that disabling moveToPath is one out of 3 options - you do have to use that if you rely on moveToPath.

    Locked.



  • I was on vacation last week. Back in the office today and took a second look at it, it is an internal DOTween thing.

    DG.Tweening.Tween:OnTweenCallback(TweenCallback`1, Tween, Int32) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:309)

    Happens regardless of moveToPath being enabled or not, as DOTween iterates over all OnWaypointChange events to the current startPoint (firing all previous events). Since DOTween comes as DLLs I am not able to "fix" it directly, but I added a workaround in SWS' OnWaypointChange method checking for the current index fired by DOTween. Will be live in the update within 24 hours.


Log in to reply