-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Hello,
How can I add an interpolation for physics body?
PhysicsGraphicalSmoothing smoothing = new PhysicsGraphicalSmoothing()
{
ApplySmoothing = 1,
};
new PhysicsGraphicalInterpolationBuffer
{
PreviousTransform = Unity.Physics.Math.DecomposeRigidBodyTransform((float4x4)pb.transform.localToWorldMatrix),
PreviousVelocity = new PhysicsVelocity(){ Linear = float3.zero, Angular = float3.zero}
};
Hot to add it to the rigidbody's entity? or to PhysicsWorld?
For example, for MotionVelocity I see we can add it like this:
var motionVelocities = PhysicsWorld.MotionVelocities;
motionVelocities[dynamicIndex] = new MotionVelocity()...
and then finding it like
int rbIndex = PhysicsWorld.GetRigidBodyIndex(new Entity() { Index = pb.Entity });
var rb = PhysicsWorld.Bodies[rbIndex];
Or how can I get access to an entity with that physics body to add a new component? like
var entityManager = Unity.Entities.World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(new Entity() { Index = pb.Entity }, new PhysicsGraphicalSmoothing());
entityManager.AddComponentData(new Entity() { Index = pb.Entity }, new PhysicsGraphicalInterpolationBuffer
{
PreviousTransform = Unity.Physics.Math.DecomposeRigidBodyTransform((float4x4)pb.transform.localToWorldMatrix),
PreviousVelocity = new PhysicsVelocity(){ Linear = float3.zero, Angular = float3.zero},
});
I am totally misunderstanding how it all works(
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels