linearGravityField() is not affecting physics bodies in the scene SceneKit
Set the "downGravityCatagory" bit mask on the node:
dice.categoryBitMask = downGravityCatagory;
the physics's categoryBitMask is for physics collisions only.
Physics forces not affecting dynamic body Scenekit
For physics to simulate the node needs a physicsShape assigned, which is achieved with;
_secondNode.physicsBody.physicsShape = [SCNPhysicsShape shapeWithGeometry:[SCNSphere sphereWithRadius:2] options:nil];
Make particle system only be affected by certain categories of physics fields in SceneKit?
Ok, I don't know how I overlooked this, but the answer is right in the documentation for SCNPhysicsField
's categoryBitMask
property.
To determine whether a field affects the particles spawned by an
SCNParticleSystem object, SceneKit performs the same check using the
categoryBitMask property of the node containing the particle system.
Making physics bodies responsive to fields but not to other physics bodies
You should set
body.physicsBody?.collisionBitMask = 0
collisionBitMask
- A mask that defines which categories of physics bodies can collide with this physics body. IF the value is not set your PhysicsBody
collides with every other PhysicsBodies
, If value is set to 0 your PhysicsBody
do not collide with other PhysicsBodies
I you set collisionBitMask = 0
your body
node will go through all other nodes, if you whant it to collide you need to set node physicsBody?.collisionBitMask
(for example if you whant your node to collide only with ball and wall physicsBody?.collisionBitMask = kCategoryWall | kCategoryBall
)
I hope it was helpfull
Can't prevent physics field from interacting with particle system using category bit mask
I've discovered that the category bit mask cannot be set on the physics field within the scene graph builder, it isn't exposed. It must be set programatically. I was setting the mask on the physics field node, hence why it wouldn't work.
Related Topics
Backgroundtimeremaining Returns (35791394 Mins)
Swift Computed Properties Cannot Be Used in Init
Why Is Uisearchcontroller Changing the Navigation Bar Colors
Format Currency in Textfield in Swift on Input
Dynamic Uitablecellview Height
Xcode 11 Archive Gives Phasescriptexecution Failed
Scroll All the Way Down to the Bottom of Uitableview
iOS PDFkit Displaymode = Singlepage Only Shows the First Page of the PDF
How to Add Two or More Buttons to Annotationview: Mkannotationview
Dynamically Passing Closure with Keypaths to a Sorting Function
Viewing Os_Log Messages in Device Console
Gmsmapview Animatetocameraposition Zoom in - Zoom Out Animation
Generics Type Constraint VS Inheritance
Is Weak Self Needed for Table View Cell Button Closure
How to Make Watchkit Extension App and My iPhone App Share the Same Icloud Databases
How to Properly Refresh a Uinavigationbar