I tried this code but not working.
turretAspect.LocalTransform.ValueRW.Rotation = math.mul(math.inverse(playerAspect.LocalToWorld.ValueRO.Value),
quaternion.LookRotationSafe(dir, math.up()).value);
I tried this code but not working.
turretAspect.LocalTransform.ValueRW.Rotation = math.mul(math.inverse(playerAspect.LocalToWorld.ValueRO.Value),
quaternion.LookRotationSafe(dir, math.up()).value);
I found this solution:
float3 dir = float3.zero - turretAspect.LocalToWorld.ValueRO.Position;
turretAspect.LocalTransform.ValueRW.Rotation = playerAspect.LocalToWorld.ValueRW.Value.InverseTransformRotation(quaternion.LookRotationSafe(dir, math.up())).value;
This is work correctly but this time child enity shaking when rotating the parent entity.
Also this is my move code of parent entity:
foreach (var playerAspect in SystemAPI.Query<PlayerAspect>())
{
playerAspect.PhysicsVelocity.ValueRW.Linear = PlayerCar.Instance.vehicleController.rb.velocity;
entityManager.SetComponentData(playerAspect.Entity, new LocalTransform
{
Position = playerAspect.Transform.ValueRO.Position,
Rotation = PlayerCar.Instance.vehicleController.transform.rotation,
Scale = playerAspect.Transform.ValueRO.Scale
});
}