Search Unity

Resolved [1.0.0-prev.15] Setting Physics velocity is not applied to WorldTransform

Discussion in 'NetCode for ECS' started by Occuros, Nov 30, 2022.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    I just upgraded to the latest iteration (15) and my previous systems don't seem to work the same way anymore.

    When I am setting the target velocity in the following way:

    Code (CSharp):
    1.     var targetVelocity = PhysicsVelocity.CalculateVelocityToTarget(
    2.                         SystemAPI.GetComponent<PhysicsMass>(entity),
    3.                         translation, rotation,
    4.                         target, 1 / deltaTime);
    5.                     velocity = targetVelocity;
    The LocalTransform component values go to very high values, so does the PhysicsVelocity, but the WorldPosition doesn't update.

    The system runs in the `PredictedFixedStepSimulationSystemGroup` and it worked normally in the previous iterations (before the Transform System V2).

    Now I'm not sure if that might be a bug due to the new transform system, or me missing some setup to make it work properly.
     
    MagiJedi likes this.
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    895
    The WorldPosition is updated only after the TransformSystemGroup run. Before V2, the world position was always calculated on the fly.
    Now it is a cached property and does not get updated automatically as expected. This is mostly a well known problem in general.

    I would thanks you for reporting this, since it also add to the cases that need to be addressed by the new transform system.
     
    MagiJedi and Occuros like this.
  3. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Seen as in the latest release WorldPosition has been deprecated in favor of a faster TransformV2, this is no longer valid.