Physics Materials
Friction and bounciness settings.
Introduction
Friction and bounciness settings. This page provides a complete guide to physics materials in Appley, covering everything from setup to advanced techniques.
Physics is a core area of Appley. Understanding physics materials will help you build better games and use the platform more effectively. This documentation is designed for advanced level users.
Requirements
Before working with physics materials, ensure you have the following:
- An Appley project with a 3D scene
- 3D models with colliders
- Understanding of basic physics (mass, force, gravity)
- Rigidbody components on objects
Estimated Completion Time
Step-by-Step Guide
Follow these steps to work with physics materials in your Appley project:
Add rigidbody
Select the object in the hierarchy and add a rigidbody component for physics materials.
Configure collider
Set the collider shape (box, sphere, capsule, mesh) and size.
Set physics properties
Configure mass, friction, bounce, and other physics material properties.
Script forces
Use the physics API to apply forces, torques, and impulses from scripts.
Test physics
Play the game and verify the physics behavior. Adjust properties as needed.
FluxScript Example
Below is an Appley Scripting (Flux Scripting) code example demonstrating physics materials:
// Physics — Physics Materials
on start {
ball = world.spawn("sphere")
ball.setRigidbody(true)
ball.setMass(2.0)
ball.setBounce(0.8)
ball.setFriction(0.3)
ball.setPosition(0, 20, 0)
ball.applyForce(vec3(0, 0, -100))
}
on collision(other) {
if other.type == "floor" {
vel = ball.getVelocity()
ball.setVelocity(vel.x, -vel.y * 0.8, vel.z)
}
hit = physics.raycast(ball.position, vec3(0, -1, 0), 1.5)
if hit != null ball.isGrounded = true
}Node Script Example
The same logic can be implemented using Node Scripting. Here is the equivalent node graph:
[On Start] ──► [Spawn: sphere]
──► [Set Rigidbody: true, mass=2, bounce=0.8]
──► [Apply Force: (0,0,-100)]
[On Collision] ──► [Branch: "floor"]
──► [Get Velocity] ──► [Set Velocity: bounce]Interchangeable Systems
Common Mistakes
Avoid these frequent mistakes when working with physics materials:
Making all colliders mesh-accurate
Use primitive colliders (box, sphere, capsule) for performance.
Not setting rigidbody mass correctly
Heavier objects should have proportionally higher mass values.
Using continuous collision detection everywhere
Use discrete mode for slow objects; continuous only for fast ones.
Creating physics objects in on update
Spawn rigidbodies in on start or via timers, never per-frame.
Troubleshooting
If you encounter issues with physics materials, try these solutions:
Objects fall through the floor
Physics is jittery/unstable
Fast objects tunnel through walls
Joints behave unpredictably
Performance Tips
Optimize your use of physics materials with these performance tips:
- Use primitive colliders instead of mesh colliders for static objects.
- Set up collision layers to control which objects interact with each other.
- Use fixed timestep for consistent physics across different frame rates.
- Put sleeping rigidbodies to rest when they are not moving to save CPU.
Related Pages
Explore these related documentation pages:
Example Project
Download a complete example project demonstrating physics materials:
