class PhysicsFeature(
val spatial: SpatialInterface,
val useGrabbablePhysics: Boolean = true,
worldBounds: PhysicsWorldBounds? = null,
gravity: Vector3 = Vector3(0.0f, -9.81f, 0.0f),
sleepSpeed: Float = 0.005f,
timeBeforeSleep: Float = 0.5f,
) : AbstractSpatialFeaturePhysicsFeature
(
spatial
, useGrabbablePhysics
, worldBounds
, gravity
, sleepSpeed
, timeBeforeSleep
)
|
Signature
constructor(
spatial: SpatialInterface,
useGrabbablePhysics: Boolean = true,
worldBounds: PhysicsWorldBounds? = null,
gravity: Vector3 = Vector3(0.0f, -9.81f, 0.0f),
sleepSpeed: Float = 0.005f,
timeBeforeSleep: Float = 0.5f,
)Parameters useGrabbablePhysics: Boolean
Whether to enable automatic physics state changes for grabbable entities
sleepSpeed: Float
Speed in m/s that a body has to stay below to fall asleep. Default is 0.005.
timeBeforeSleep: Float
How long, in seconds, a body has to stay below sleepSpeed to fall asleep. Default is 0.5.
Returns PhysicsFeature |
spatial
: SpatialInterface
[Get] |
The SpatialInterface for interfacing with the native physics engine
Signature
val spatial: SpatialInterface |
useGrabbablePhysics
: Boolean
[Get] |
Whether to enable automatic physics state changes for grabbable entities
Signature
val useGrabbablePhysics: Boolean = true |
componentsToRegister
()
|
Override this function to define a list of components that should be used by the application.
Signature
open override fun componentsToRegister(): List<ComponentRegistration> Returns List<ComponentRegistration>
A list of ComponentRegistration objects representing the components to register.
|
earlySystemsToRegister
()
|
Override this method to register your systems that should be executed with PriorityGroup EARLY.
Signature
open fun earlySystemsToRegister(): List<SystemBase> |
enablePhysicsDebugLines
(
enabled
)
|
Toggles debug lines for visualization of the physics simulation. The color of the lines correspond to the state of the physics objects.
This is useful for debugging physics interactions and understanding how physics bodies are behaving in the scene.
Signature
fun enablePhysicsDebugLines(enabled: Boolean) Parameters enabled: Boolean
Whether to enable or disable physics debug lines.
|
getDependencies
()
|
Override this method to define a list of dependencies required by this feature. This will be verified at runtime.
Example:
// MyCustomFeature.kt
override fun getDependencies(): List<KClass<out SpatialFeature>> {
return listOf(ToolkitFeature::class)
}
@return A list of SpatialFeature classes representing the dependencies.
Signature
open fun getDependencies(): List<KClass<out SpatialFeature>> Returns List<KClass<out SpatialFeature>> |
getGravity
()
|
Get the gravity vector for the physics world. Changing the values of the returned Vector3 will not affect the world's gravity without calling setGravity()
Signature
fun getGravity(): Vector3 Returns Vector3 |
lateSystemsToRegister
()
|
Override this method to register your systems that should be executed with PriorityGroup LATE.
Signature
open override fun lateSystemsToRegister(): List<SystemBase> |
loadLibrary
(
libName
)
|
Loads a native library using the attached LibraryLoader.
Signature
open override fun loadLibrary(libName: String) Parameters libName: String
The name of the library to load (without "lib" prefix or ".so" suffix).
|
onAttach
(
libraryLoader
)
|
Stores the LibraryLoader reference for use in lifecycle methods. Subclasses should not override this method unless they need to perform additional setup, in which case they must call super.onAttach(libraryLoader).
Signature
open override fun onAttach(libraryLoader: LibraryLoader) Parameters |
onCreate
(
savedInstanceState
)
|
Called when the application is created. Override this method to perform actions during the OnCreate() lifecycle of the application.
Signature
open override fun onCreate(savedInstanceState: Bundle?) Parameters savedInstanceState: Bundle?
The saved instance state of the application.
|
onDestroy
()
|
Called when the application is in onDestroy callback. Be aware that onDestroy() is not guaranteed to be called. Override this method to perform actions during the OnDestroy() lifecycle of the application.
Signature
open fun onDestroy() |
onPauseActivity
()
|
Called when the activity is in onPause callback. Override this method to perform actions during the OnPause() lifecycle of the application.
Signature
open fun onPauseActivity() |
onResume
()
|
Called when the application is resumed. Override this method to perform actions during the OnResume() lifecycle of the application.
Signature
open fun onResume() |
onSceneReady
()
|
Called when the scene is ready. Override this method to perform actions during the OnSceneReady() lifecycle of the application.
Signature
open fun onSceneReady() |
onSpatialShutdown
()
|
Called when the application is shutting down. Clean up all Spatial resources for your feature, e.g. entites.destroy(), in this callback.
Signature
open fun onSpatialShutdown() |
onStart
()
|
Called when the application is started. Override this method to perform actions during the OnStart() lifecycle of the application.
Signature
open fun onStart() |
onStopActivity
()
|
Called when the activity is in onStop callback. Be aware that onStop() is not guaranteed to be called. Override this method to perform actions during the OnStop() lifecycle of the application.
Signature
open fun onStopActivity() |
onVRPause
()
|
Called when the VR mode is paused. Override this method to perform actions during the OnVRPause() lifecycle of the application.
Signature
open fun onVRPause() |
onVRReady
()
|
Called when the VR mode is ready. Override this method to perform actions during the onVRReady() lifecycle of the application.
Signature
open fun onVRReady() |
preRuntimeOnCreate
(
savedInstanceState
)
|
Called before the application's onCreate() method is called. Override this method to perform actions before the rest of the OnCreate() lifecycle of the application.
Signature
open override fun preRuntimeOnCreate(savedInstanceState: Bundle?) Parameters savedInstanceState: Bundle?
The saved instance state of the application.
|
registerRequiredOpenXRExtensions
()
|
Override this function to define a list of required OpenXR extensions that should be enabled by your application.
Signature
open fun registerRequiredOpenXRExtensions(): List<String> Returns List<String>
A list of strings representing the required OpenXR extensions.
|
setGravity
(
gravity
)
|
Set the gravity vector for the physics world. This can be called at any time.
Signature
fun setGravity(gravity: Vector3) Parameters gravity: Vector3 |
setSleepSettings
(
speed
, timeBeforeSleep
)
|
Sets when bodies fall asleep, for every body in the world. This can be called at any time.
A body falls asleep once it has moved slower than speed for timeBeforeSleep seconds. A sleeping body costs no CPU and stays still until something touches or moves it. Sleep stops a body dead, so a high speed makes slow objects visibly halt. Use Physics.allowSleeping to keep a particular body awake.
Signature
fun setSleepSettings(speed: Float, timeBeforeSleep: Float) Parameters speed: Float
Speed in m/s that a body has to stay below to fall asleep. Default is 0.005.
timeBeforeSleep: Float
How long, in seconds, a body has to stay below speed. Default is 0.5.
|
systemsToRegister
()
|
Override this method to register your systems that should be executed PriorityGroup NORMAL.
Signature
open override fun systemsToRegister(): List<SystemBase> |