I'm trying to simulate a soft, bouncy floor (i.e. a trampoline) so that when a significant impulse is given at one point, it causes objects nearby to bounce off in random direction.
However, I'm having difficulties trying to reproduce such behavior in SceneKit.
Here are what I have tried so far:
- Call
ground.physicsBody!.applyForce(SCNVector3Make(0, -999999, 0), atPosition: pos, impulse: true)on the ground node that has a physics body of type.Kinematicattached to it. - Call
ground.physicsBody!.applyForce(SCNVector3Make(0, -999999, 0), atPosition: pos, impulse: true)on the ground node that has a physics body of type.Staticattached to it. - Create a
SCNPhysicsField.radialGravityField(), attach it to an invisible node, position the node below the floor, and finally give it a negative strength in order to repel objects away.
Both 1 and 2 do not work, no matter how great the given impulse is. Also I verified restitution > 0 on both floor and object. Note that while directly applying impulses to objects works, I'd like to have these impulses (i.e. objects bouncing off a trampoline) automatically calculated by the physics engine in regard to the distance and direction of the previous impulse (i.e. a person jumping on the trampoline) rather than assigning them manually.
Option 3 somewhat gives the effect I want, but it rather applies a continuous force against objects rather than instantaneous.