I am working on adding synchronized physical properties to EntityEquipment
in TableTopKit,
allowing seamless coordination during GroupActivities
sessions between players.
Treating EntityEquipment's state to DieState is not a way, because it doesn't support custom collision shapes.
I have also tried adding PhysicsBodyComponent
and CollisionComponent
to EntityEquipment's Entity.
However, the main issue is that the position of EntityEquipment itself does not synchronize with the Entity's physics body, resulting in two separate instances of one object.
struct PlayerPawn: EntityEquipment {
let id: ID
let entity: Entity
var initialState: BaseEquipmentState
init(id: ID, entity: Entity) {
self.id = id
let massProperties = PhysicsMassProperties(mass: 1.0)
let material = PhysicsMaterialResource.generate(friction: 0.5, restitution: 0.5)
let shape = ShapeResource.generateBox(size: [0.4, 0.2, 0.2])
let physicsBody = PhysicsBodyComponent(massProperties: massProperties, material: material, mode: .dynamic)
let collisionComponent = CollisionComponent(shapes: [shape])
entity.components.set(physicsBody)
entity.components.set(collisionComponent)
self.entity = entity
initialState = .init(parentID: .tableID, pose: .init(position: .init(), rotation: .zero), entity: self.entity)
}
}
I’d appreciate any guidance on the recommended approach to adding synchronized physical properties to EntityEquipment.
Hello @matt_novoselov,
As you noted, TabletopKit's physics simulation supports the shapes listed here. For other shapes including a custom shape, I encourage you to please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.
If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?
startinteraction
is a mechanism to programmatically manipulate TabletopKit equipment that is synchronized over the network. Using this along with setPose
is an appropriate way to use another physics simulation alongside TabletopKit when simulating unsupported shapes.
Thanks,
John