It is my first question here. I hope it is not so stupid question 😀
In Apple Vision pro I’ve make a ground :
if let floor = scene.findEntity(named: "Sol")
{
floor.components[PhysicsBodyComponent.self] = .init(
massProperties: .default,
material: .generate( staticFriction: 1, dynamicFriction: 0.5, restitution: 0),
mode: .static)
floor.generateCollisionShapes( recursive: false)
floor.components.set( ImageBasedLightComponent(source: .single( environmentLight!)))
floor.components.set( ImageBasedLightReceiverComponent( imageBasedLight: floor))
}
and I make a ball :
if let sphere = scene.findEntity(named: "Boule_Chrome")
{
Set_Entity_Params( entity: sphere, mass: 0.70, friction: kBoules_Friction, rebond: 0.0005, ralentissement: 1)
sphere.components.set( ImageBasedLightComponent(source: .single( environmentLight!)))
sphere.components.set( ImageBasedLightReceiverComponent( imageBasedLight: sphere))
}
.
..
func Set_Entity_Params( entity: Entity, mass: Float, friction: Float, rebond: Float, ralentissement: Float, mode: PhysicsBodyMode = .dynamic)
{
entity.components.set( InputTargetComponent())// Permet d'etre saisisable à la main
entity.components.set( GroundingShadowComponent(castsShadow: true))
var spherePhysics = PhysicsBodyComponent( massProperties: .init(mass: mass), material: .generate(staticFriction: friction, dynamicFriction: friction, restitution: rebond), mode: mode)
spherePhysics.isRotationLocked = (x:false, y:false, z:false)
spherePhysics.isContinuousCollisionDetectionEnabled = true
spherePhysics.angularDamping = 0.9
spherePhysics.linearDamping = ralentissement
entity.components.set( spherePhysics)
}
To launch the ball on the ground, I just apply a linear Velocity :
sphere.components[PhysicsMotionComponent.self]?.linearVelocity = SIMD3(0, 0, -7.8)
All is perfect, the ball is launched, touch the ground and move on the ground, that’s perfect. EXCEPTING the ball not roll on the ground, it slide !!!! 🙁
Some one could help me to have the ball rolling on the ground please ?
Cheers
Mathis
Stéphane MAUREL is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.