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.
callback
Callback functionentity
The entity that has been enteredcollider
The entity that was hitdirection
The direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down sidepoint
The normal of contact point
void PhysicsAPI.OnHitEnter(YaEntity entity, function callback<YaEntity, number, float3>)¶
Fired when the entity has been hit by a character.
entity
Entitycallback
Callback functionentity
The entity that has been hitdirection
The direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down sidepoint
The normal of contact point
void PhysicsAPI.OnHitExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity stops being hit by the character.
entity
Entitycallback
Callback functionentity
The entity that has been hit
void PhysicsAPI.OnTriggerEnter(function callback<YaEntity, YaEntity>)¶
Fired when the character enters a trigger.
callback
Callback functiontrigger
The entity that has been enteredentity
The entity involved in this collision
void PhysicsAPI.OnTriggerEnter(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity enters a trigger box.
entity
Triggercallback
callback functionentity
The entity that enters a trigger box
void PhysicsAPI.OnTriggerExit(function callback<YaEntity, YaEntity>)¶
Fired when the character exit a trigger.
callback
callback functiontrigger
The entity involved in this collisionentity
The entity that has been entered
void PhysicsAPI.OnTriggerExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity exits a trigger box.
entity
Triggercallback
callback functionentity
The entity that enters a trigger box
void PhysicsAPI.OnContactEnter(function callback<YaEntity, YaEntity>)¶
Fired when the rigidbody enters another entity.
callback
Callback functionrigidbody
The rigidbody entity involved in this contactentity
The entity involved in this contact
void PhysicsAPI.OnContactExit(function callback<YaEntity, YaEntity>)¶
Fired when the rigidbody exits another entity.
callback
Callback functionrigidbody
The rigidbody entity involved in this contactentity
The entity involved in this contact
void PhysicsAPI.OnContactEnter(YaEntity entity, function callback<YaEntity>)¶
Fired when the character enters another character or rigidbody.
entity
The rigidbody entitycallback
Callback functionentity
The entity involved in this contact
void PhysicsAPI.OnContactExit(YaEntity entity, function callback<YaEntity>)¶
Fired when the entity exits another character or rigidbody.
entity
The rigidbody entitycallback
Callback functionentity
The 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
entity
The rigidbody to apply a force toforce
Force 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
entity
The rigidbody to applies an impulse.force
Force 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
entity
The rigidbody to apply a torque.torque
Torque 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
entity
The rigidbody to apply a forceforce
Force vectorpos
Global 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
entity
The rigidbody to apply a forceforce
Force vectorpos
Local 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
entity
The rigidbody to apply a forceforce
Local Force vectorpos
Local 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
entity
The rigidbody to apply an explosionexplosionForce
The force of the explosionexplosionPosition
The centre of the sphere within which the explosion has its effectradius
The radius of the sphere within which the explosion has its effectupwardsModifier
Adjustment 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
entity
The rigidbody to apply a force toangVel
The 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
entity
The rigidbody to apply a force tolinVel
The linear velocity vector
void PhysicsAPI.DisableGravity(YaEntity entity)¶
Disable the entity gravity
entity
Rigidbody entity
void PhysicsAPI.EnableGravity(YaEntity entity)¶
Enable the entity gravity
entity
Rigidbody entity
float3? PhysicsAPI.GetLinearVelocity(YaEntity entity)¶
ReturnsLinear velocity.
Gets the linear velocity.
entity
Rigidbody 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
entity
Entityvalue
False if, collisions will be turned off
boolean PhysicsAPI.GetCollidable(YaEntity entity)¶
ReturnsGet collisions on the entity
Get collisions on the entity.
entity
Entity
void PhysicsAPI.IgnoreCameraRaycast(YaEntity entity, boolean value)¶
Set whether the entity collides with the camera
entity
Entityvalue
Value
YaQueryResult PhysicsAPI.RaycastSingle(float3 origin, float3 direction, YaQueryParameter parameter)¶
ReturnsQueryResult
Returns only the first entity contacted with the raycast.
origin
The origin point of the raycastdirection
The direction of the raycastparameter
YaQueryParameter
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.
origin
The origin point of the raycastdirection
The direction of the raycastparameter
YaQueryParameter
float3? PhysicsAPI.GetBoundsMinimum(YaEntity entity)¶
ReturnsBounds minimum
Returns the minimum value of the entity's physical bounding box
entity
Entity
float3? PhysicsAPI.GetBoundsMaximum(YaEntity entity)¶
ReturnsBounds maximum
Returns the maximum value of the entity's physical bounding box
entity
Entity
Array<YaEntity> PhysicsAPI.Overlap(float3 origin, YaQueryParameter parameter)¶
ReturnsEntity list
Queries for all entities in a certain area.
origin
originparameter
parameter