Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong offset of graphical object in SetTransformOffsets #578

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

GhoShot
Copy link
Contributor

@GhoShot GhoShot commented Dec 21, 2023

Fixed wrong offset of graphical objects in prediction, causing them to show in the opposite direction during reversed calculation.

Simple explanation:

  1. VectorAB (abbreviated as Vab) = PointB(Pb) - Pa, then Pa + Vab = Pa + (Pb - Pa) = Pb ;
  2. _graphicalInstantiatedOffsetPosition = graphicaltarget - transformpoint;
  3. So: _graphicalObject.position= transform.position + _graphicalInstantiatedOffsetPosition = transform.position + (graphicaltarget - transform.position)

Thats it. the _graphicalInstantiatedOffsetRotation can concluded by similar reasoning

The offset between the child object and the parent was mistakenly set in the opposite direction. This issue has been fixed in the latest commit.
@GhoShot
Copy link
Contributor Author

GhoShot commented Dec 28, 2023

fixes #582

@FirstGearGames
Copy link
Owner

This was resolved in prediction v2 but apparently missed for pv1.
There is another variant which will be fixed in the upcoming releases as well, though it's not used at this time.

        public static TransformProperties GetTransformOffsets(this Transform t, Transform target)
        {
            if (target == null)
                return default;

            return new TransformProperties(
                (target.position - t.position),
                (target.rotation * Quaternion.Inverse(t.rotation)),
                (target.localScale - t.localScale)
                );
        }

@FirstGearGames FirstGearGames merged commit 1553f2e into FirstGearGames:main Dec 28, 2023
FirstGearGames pushed a commit that referenced this pull request Jan 12, 2024
- Added TransportManager.Get/SetMTUReserve(int) to allow reserving bytes in buffers, such as use with IntermediateLayer to insert encryption data. Reserving bytes does not consume more bandwidth if bytes are not filled.
- Improved TransportManager.GetMTU methods to consider reserve.
- Improved exposed TimeManager.PingInterval.
- Fixed Fish-Networking menu item order.
- Improved created replicates which arrive after the run tick are now run in replays instead of twice.
- Changed ReplicateState.UserCreated renamed to CurrentCreated for clarity.
- Changed ReplicateState.Predicted renamed to CurrentPredicted for clarity.
- Changed ReplicateState.ReplayedPredicted/UserCreated renamed to Replayed.
- Added ReplicateState.Future to indicate future prediction of objects.
- Changed SceneLoad/UnloadData PreferredScene is now a structure.
- Added SceneLoad/UnloadData PreferredScene can now specify different scenes for client and server.
- Fixed Prediction v2 reconcile desyncs for NonAuthoritative.
- Fixed Prediction v2 reconcile desyncs for Authoritative.
- Improved RigidbodyPauser to be simplified and more flexible for edge-case setups.
- Fixed Prediction v2 garbage allocation from physics.
- Fixed Prediction v2 excessive replays of remote objects when local client was not moving.
- Removed NetworkManager.StaticLogXYZ methods.
- Added NetworkManagerExtensions.Log/Warnig/Error.
- Added Log/Warning/Error extensions for NetworkManager references; null references may be used.
- Improved NetworkManager logging methods now use Unity debug when NetworkManager does not exist in any scene.
- Improved ServerManager.ShareIds made public.
- Improved BufferLast always uses reliable channel for new observers now.
- Fixed a SyncType not being set dirty by server within OnStartServer due to no observers count, resulting in predicted spawners not getting the new value update.
- Added Prediction v2 teleport option for graphical object.
- Improved List.AddUnique now returns if added, as well value no longer boxes. (#579)(#580)
- Fixed preferred scene not being applied to global scenes for late joiners (#585)
- Fixed inversed transform offsets in GetTransformOffsets and SetTransformOffsets. (#578)
- Fixed DistanceCondition causing flickering due to incorrect hide distance calculation. (#576)
FirstGearGames pushed a commit that referenced this pull request Jan 14, 2024
- Fixed preferred scene not being applied to global scenes for late joiners (#585)
- Fixed TicksToTime(PreciseTick pt) returning incorrect values.
- Improved exposed TimeManager.PingInterval.
- Improved accuracy printout for ColliderRollback demo.
- Improved PreciseTick legibility and potentially accuracy slightly.
- Improved List.AddUnique now returns if added, as well value no longer boxes. (#579)
- Fixed inversed transform offsets in GetTransformOffsets and SetTransformOffsets. (#578)
- Fixed PredictedBullet, predicted spawning example, within Rigidbody Prediction v1 demo.
- Improved notes and explanations on predicted spawning example.
- Fixed a SyncType not being set dirty by server within OnStartServer due to no observers count, resulting in predicted spawners not getting the new value update.
- Removed all prediction v2 logic and demos. Only v4 and up will support prediction v2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants