How to freeze/constraint entity position and rotation in DOTS

What’s the way to constraint position and rotation for entities?
I’ve added Physics Body and set every axis of Inertia Tensor to infinity but it’s still rotating.

I want to make my “character” to move and rotate in 2D perspective


May be because I apply linear Impulse in this System?

using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Extensions;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.InputSystem;

[UpdateBefore(typeof(TransformSystemGroup))]
public partial struct FartManMovementSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        EntityQueryBuilder builder = new EntityQueryBuilder(Allocator.Temp).WithAll<PhysicsWorldSingleton>();
        EntityQuery singletonQuery = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntityQuery(builder);
        PhysicsWorldSingleton physicsWorldSingleton = singletonQuery.GetSingleton<PhysicsWorldSingleton>();

        FartManMoveInputComponent playerInput = SystemAPI.GetSingleton<FartManMoveInputComponent>();
        JobHandle handle = new FartDistanceJob { playerInput = playerInput, physicsWorld = physicsWorldSingleton }.Schedule(state.Dependency);
        handle = new FartManMoveJob { playerInput = playerInput }.Schedule(handle);
        state.Dependency = handle;
        handle.Complete();
        SystemAPI.SetSingleton(new FartManMoveInputComponent
        {
            fartPower = 0,
            fartPowerMuliplyer = SystemAPI.GetSingleton<FartManMoveInputComponent>().fartPowerMuliplyer,
            rotationVector = 0,
            rotationPower = SystemAPI.GetSingleton<FartManMoveInputComponent>().rotationPower
        });
    }
}
public partial struct FartManMoveJob : IJobEntity
{
    public FartManMoveInputComponent playerInput;
    [BurstCompile]
    public void Execute(BodyPartTagComponent bodyPart, ref PhysicsVelocity velocity, PhysicsMass mass, ref LocalTransform transform)
    {
       
        //body impulse
        if (bodyPart.part == 0 && playerInput.fartPower > 0 && bodyPart.goodDistance)
            velocity.ApplyLinearImpulse(mass, transform.Up() * playerInput.fartPower);
        //head impulse
        if (bodyPart.part == 1 && playerInput.rotationVector != 0)
            velocity.ApplyLinearImpulse(mass, transform.Right() * playerInput.rotationVector * playerInput.rotationPower);
    }
}
public partial struct FartDistanceJob : IJobEntity
{
    public FartManMoveInputComponent playerInput;
    [Unity.Collections.ReadOnly] public PhysicsWorldSingleton physicsWorld;
    [BurstCompile]
    public void Execute(ref BodyPartTagComponent bodyPart, ref PhysicsVelocity velocity, PhysicsMass mass, LocalTransform transform)
    {
        if (bodyPart.part == 0)
        {
            var collisionWorld = physicsWorld.CollisionWorld;
            RaycastInput input = new RaycastInput()
            {
                Start = transform.Position,
                End = -transform.Up(),
                Filter = new CollisionFilter()
                {
                    BelongsTo = ~0u,
                    CollidesWith = 1 << 6,
                    GroupIndex = 0
                }
            };
            Unity.Physics.RaycastHit hit = new Unity.Physics.RaycastHit();
            bool isHit = collisionWorld.CastRay(input, out hit);
            if (isHit && math.distance(transform.Position, hit.Position) < 5f)
            {
                bodyPart.goodDistance = true;
                Debug.Log("Hit: " + bodyPart.goodDistance);
            }
            else
            {
                bodyPart.goodDistance = false;
                Debug.Log("Hit: " + bodyPart.goodDistance);
            }
        }
    }
}

Can you add some debug log prints of the PhysicsMass content please?
I imagine it’s not what you imagine because you have a Rigidbody and a PhysicsBody in your game object. The baking then picks up the Rigidbody first and ignores the PhysicsBody properties.
I suggest you remove the Rigidbody component in your game object.

Yes, removed RB and added Physics Shape works for me, thx. But is there the way to use joints like we do it with regular RB? My dummy is beheaded how.(

I guess you mean constraining the different motion components but with the Rigidbody constraint properties.
These are some of the few remaining, not yet baked properties in Unity Physics. I’ll make sure we have an internal report for this.
In the meantime you could modify the inertia tensor at edit time using the Rigidbody mass property override options, or add a custom baking component which does that via a baking system that runs after the RigidbodyBakingSystem and which you then add alongside the Rigidbody component.