PhysicsAPI¶
PhysicsAPI is an interface which defines properties, events, and functions for objects which simulates physics.Functions¶
void PhysicsAPI.OnHitEnter(function callback<YaEntity, YaEntity, number, float3>)¶
Fired when the entity has been hit.
callbackCallback functionentityThe entity that has been enteredcolliderThe entity that was hitdirectionThe direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down sidepointThe normal of contact point
void PhysicsAPI.OnHitEnter(YaEntity entity, function callback<YaEntity, number, float3>)¶
Fired when the entity has been hit by a character.
entityEntitycallbackCallback functionentityThe entity that has been hitdirectionThe direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down sidepointThe normal of contact point
void PhysicsAPI.OnHitExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity stops being hit by the character.
entityEntitycallbackCallback functionentityThe entity that has been hit
void PhysicsAPI.OnTriggerEnter(function callback<YaEntity, YaEntity>)¶
Fired when the character enters a trigger.
callbackCallback functiontriggerThe entity that has been enteredentityThe entity involved in this collision
void PhysicsAPI.OnTriggerEnter(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity enters a trigger box.
entityTriggercallbackcallback functionentityThe entity that enters a trigger box
void PhysicsAPI.OnTriggerExit(function callback<YaEntity, YaEntity>)¶
Fired when the character exit a trigger.
callbackcallback functiontriggerThe entity involved in this collisionentityThe entity that has been entered
void PhysicsAPI.OnTriggerExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity exits a trigger box.
entityTriggercallbackcallback functionentityThe entity that enters a trigger box
void PhysicsAPI.OnContactEnter(function callback<YaEntity, YaEntity>)¶
Fired when the rigidbody enters another entity.
callbackCallback functionrigidbodyThe rigidbody entity involved in this contactentityThe entity involved in this contact
void PhysicsAPI.OnContactExit(function callback<YaEntity, YaEntity>)¶
Fired when the rigidbody exits another entity.
callbackCallback functionrigidbodyThe rigidbody entity involved in this contactentityThe entity involved in this contact
void PhysicsAPI.OnContactEnter(YaEntity entity, function callback<YaEntity>)¶
Fired when the character enters another character or rigidbody.
entityThe rigidbody entitycallbackCallback functionentityThe entity involved in this contact
void PhysicsAPI.OnContactExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity exits another character or rigidbody.
entityThe rigidbody entitycallbackCallback functionentityThe entity involved in this contact
void PhysicsAPI.AddForce(YaEntity entity, float3 force)¶
Applies a force to the rigidbody.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a force toforceForce vector
void PhysicsAPI.AddImpulseForce(YaEntity entity, float3 force)¶
Applies an impulse to the rigidbody.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to applies an impulse.forceForce vector
void PhysicsAPI.AddTorque(YaEntity entity, float3 torque)¶
Applies a torque to the rigidbody.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a torque.torqueTorque vector
void PhysicsAPI.AddForceAtPos(YaEntity entity, float3 force, float3 pos)¶
Applies a force at the specified position.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a forceforceForce vectorposGlobal position vector
void PhysicsAPI.AddForceAtLocalPos(YaEntity entity, float3 force, float3 pos)¶
Applies a force at the specified local position.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a forceforceForce vectorposLocal position vector
void PhysicsAPI.AddLocalForceAtLocalPos(YaEntity entity, float3 force, float3 pos)¶
Applies a local force at the specified local position.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a forceforceLocal Force vectorposLocal position vector
void PhysicsAPI.AddExplosionImpulseForce(YaEntity entity, number explosionForce, float3 explosionPosition, number radius, number upwardsModifier)¶
Applies an explosion at the specified position.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply an explosionexplosionForceThe force of the explosionexplosionPositionThe centre of the sphere within which the explosion has its effectradiusThe radius of the sphere within which the explosion has its effectupwardsModifierAdjustment to the apparent position of the explosion to make it seem to lift objects
void PhysicsAPI.SetAngularVelocity(YaEntity entity, float3 angVel)¶
Sets the angular velocity.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a force toangVelThe angular velocity vector
void PhysicsAPI.SetLinearVelocity(YaEntity entity, float3 linVel)¶
Sets the linear velocity.
Note: If called on the client side, the object may be inconsistent with the server
entityThe rigidbody to apply a force tolinVelThe linear velocity vector
void PhysicsAPI.DisableGravity(YaEntity entity)¶
Disable the entity gravity
entityRigidbody entity
void PhysicsAPI.EnableGravity(YaEntity entity)¶
Enable the entity gravity
entityRigidbody entity
float3? PhysicsAPI.GetLinearVelocity(YaEntity entity)¶
ReturnsLinear velocity.
Gets the linear velocity.
entityRigidbody entity
void PhysicsAPI.SetCollidable(YaEntity entity, boolean value)¶
Enables collisions on the entity.
Note: If called on the client side, the object may be inconsistent with the server
entityEntityvalueFalse if, collisions will be turned off
boolean PhysicsAPI.GetCollidable(YaEntity entity)¶
ReturnsGet collisions on the entity
Get collisions on the entity.
entityEntity
void PhysicsAPI.IgnoreCameraRaycast(YaEntity entity, boolean value)¶
Set whether the entity collides with the camera
entityEntityvalueValue
YaQueryResult PhysicsAPI.RaycastSingle(float3 origin, float3 direction, YaQueryParameter parameter)¶
ReturnsQueryResult
Returns only the first entity contacted with the raycast.
originThe origin point of the raycastdirectionThe direction of the raycastparameterYaQueryParameter
Array<YaQueryResult> PhysicsAPI.RaycastAll(float3 origin, float3 direction, YaQueryParameter parameter)¶
ReturnsList of QueryResult
Returns all the entities contacted with the raycast. Note that the order of the results is undefined.
originThe origin point of the raycastdirectionThe direction of the raycastparameterYaQueryParameter
float3? PhysicsAPI.GetBoundsMinimum(YaEntity entity)¶
ReturnsBounds minimum
Returns the minimum value of the entity's physical bounding box
entityEntity
float3? PhysicsAPI.GetBoundsMaximum(YaEntity entity)¶
ReturnsBounds maximum
Returns the maximum value of the entity's physical bounding box
entityEntity
Array<YaEntity> PhysicsAPI.Overlap(float3 origin, YaQueryParameter parameter)¶
ReturnsEntity list
Queries for all entities in a certain area.
originoriginparameterparameter