Libraries.Game.Physics.PhysicsProperties2D Documentation
This class is a property holder for a 2D mass. This class is used internally by Item2D class.
Inherits from: Libraries.Language.Object
Variables Table
Variables | Description |
---|---|
integer NON_RESPONSIVE | static object |
integer UNMOVABLE | static object |
integer RESPONSIVE | object governed by kinematics (meaning, the object is affected by linear velocity and angular velocity settings) |
Actions Documentation
ApplyAngularImpulse(number impulse)
This action applied an angular impulse to the object which will cause the object to have a sudden change in angular velocity.
Parameters
- number impulse: The magnitude of the angular impulse.
ApplyForce(Libraries.Compute.Vector2 force, Libraries.Compute.Vector2 point)
This action applies the force that you passed in to a point that you passed in.
Parameters
- Libraries.Compute.Vector2: The force in global coordinates that you want to apply.
- Libraries.Compute.Vector2: The point in the global coordinants that you want the force to be applied to.
ApplyForceToCenter(Libraries.Compute.Vector2 force)
This action applies a force to the center pf mass of the object.
Parameters
- Libraries.Compute.Vector2: The force in global coordinates that you want to apply.
ApplyLinearImpulse(Libraries.Compute.Vector2 impulse, Libraries.Compute.Vector2 point)
This action applies a linear impulse to the object at a specified point, which will lead to a sudden change in linear velocity of the object. This will also lead to a sudden change in angular velocity of the object if the linear impulse is not applied at the center of mass of the object.
Parameters
- Libraries.Compute.Vector2: The impulse vector in global coordinates that you want to apply to the object.
- Libraries.Compute.Vector2: The point in the global coordinants that you want the linear impulse to be applied to.
ApplyTorque(number torque)
This action applies a torque to the center of mass of the object, which means this torque will only affect the angular velocity of the object but not the linear velocity of the object.
Parameters
- number torque: The magnitude of torque to the center of mass of the object.
AssignMass(number mass)
This action changes the mass of this property holder, this will not change the density of this property holder.
Parameters
- number mass: The mass of the object.
CanRotate(boolean flag)
This action sets whether the 2D object attached to this property holder will be able to rotate or not.
Parameters
- boolean flag: True if this object can rotate.
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Copy()
This action allows another PhysicsProperties2D object to be assigned by the values stored inside the current PhysicsProperties2D object.
Return
Libraries.Game.Physics.PhysicsProperties2D: another PhysicsProperties2D that has the same value as the current PhysicsProperties2D.
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
FastMoving(boolean flag)
This action sets whether if the object attached to this property holder will be moving quickly. If the object will be moving fast, then there will be more careful of a calculation of how this object collides with other objects.
Parameters
- boolean flag: True if this object will be moving quickly.
GetAngularDamping()
This action gets the angular damping inside this property holder.
Return
number:
GetAngularVelocity()
This action returns the angular velocity of the 2D object.
Return
number: how fast the 2D object will rotate.
GetCollisionGroupFlag()
This action gets whether the object attached to this property holder will be inside a collision group.
Return
boolean: false if the object is not in a collision group.
GetCollisionGroupIndex()
This action gets which collision group that this object will be in.
Return
integer: the collision group that this object will be in.
GetDensity()
This action returns the density that is stored inside this property holder.
Return
number: the density of the object.
GetForce()
This action gets the force that is stored in this object.
Return
Libraries.Compute.Vector2: the force that will be applied to the object.
GetFriction()
This action gets the friction that is stored inside this property holder.
Return
number: the coefficient of friction.
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetInertia()
This action returns the mass moment of inertia about the object's local origin (NOTE: not the mass moment of inertia about the object's center of mass).
Return
number: the mass moment of inertia about the object's local origin.
GetInverseInertia()
This action returns the reciprocal of the mass moment of inertia about the object's center of mass.
Return
number: the reciprocal of the mass moment of inertia about the object's center of mass.
GetInverseMass()
This action returns the reciprocal of the mass (1/mass) inside this property holder.
Return
number: the (1/mass) value.
GetItem()
This action returns the Item2D that is attached to this physical properties.
Return
Libraries.Interface.Item2D: the Item2D that is has this physical properties.
GetLinearDamping()
This action gets the linear damping inside this property holder.
Return
number:
GetLinearVelocity()
This action returns both the x and y components of the linear velocity as a 2D vector.
Return
Libraries.Compute.Vector2: the x and y components of the linear velocity.
GetMass()
This action returns the mass of the object.
Return
number: the mass of the object.
GetRawInertia()
This action returns the mass moment of inertia about the object's center of mass.
Return
number: the mass moment of inertia about the object's center of mass.
GetResponsiveness()
This action returns how physics (linear velocity, angular velocity, force, torque) will affect the object. There are three possible values to be returned: 0 indicates that the object is UNMOVABLE, which means no matter what forces or torques is applied to the object, the object will not move. 1 indicates that the object is NON_RESPONSIVE, which means that only setting the angular velocity and linear velocity of this object will affect how the object behaves. 2 indicates that the object is REPONSIVE, which means that this object will behave differently when you apply forces and torques to this object.
Return
integer: Returns how physics will affect the object.
GetRestitution()
This action returns how much energy that this 3D object will loose after a collision.
Return
number: the coefficient of restitution.
GetSleepTime()
This action gets how much time that the 2D object attached to this property holder will remain in its current position.
Return
number: how much time that the 2D object attached to this property holder will remain in its current position.
GetTorque()
This action gets the torque that is stored inside this object.
Return
number: torque.
IsFastMoving()
This action tells you whether if this object will be moving quickly. If the object will be moving fast, then there will be more careful of a calculation of how this object collides with other objects.
Return
boolean: true if this object will be moving quickly.
IsRotationAllowed()
This action tells you if the 2D object attached to this property holder will be able to rotate.
Return
boolean: True if this object can rotate.
IsSimulated()
This action tells you if the object attached to this property holder is being simulated.
Return
boolean: True if you want to simulate the object.
IsSimulationRequired()
This action tells you whether if you need to move the object that is attached to this property holder.
Return
boolean: true if will require its position to be moved.
RequireSimulation(boolean flag)
This action sets whether if the object attached to this property holder will require its position to be moved.
Parameters
- boolean flag: True if will require its position to be moved.
SetAngularDamping(number angularDamping)
This action sets the angular damping inside this property holder.
Parameters
- number angularDamping: The angular damping coefficient.
SetAngularVelocity(number angularVelocity)
This action sets the angular velocity of the 2D object.
Parameters
- number angularVelocity: How fast the 2D object will rotate.
SetCollisionGroupFlag(boolean flag)
This action sets whether the object attached to this property holder will be inside a collision group.
Parameters
- boolean flag: Whether the object attached to this property holder will be inside a collision group.
SetCollisionGroupIndex(integer index)
This action sets which collision group that this object will be in.
Parameters
- integer index: The collision group that this object will be in.
SetDensity(number density)
This action changes the density that is stored inside this property holder. With the density changed, if there is a mass attached to this property holder, then the mass of the 2D object will also change based on the object's shape.
Parameters
- number density: The density of the object.
SetForce(Libraries.Compute.Vector2 force)
This action sets the force that will be applied to the object. You only want to set a force on a RESPONSIVE 2D object (an object that will respond to forces). To actually apply a force, the type of the 2D object will be checked, therefore, it is not checked here. This action is useful to clear the forces to zero, not useful in setting a specific force that you want to apply to the object. To apply a force that you want to an object, use "ApplyForce(Vector2 force, Vector2 point)" or "ApplyForceToCenter(Vector2 force)".
Parameters
- Libraries.Compute.Vector2: The force that will be applied to the object
SetFriction(number friction)
This action sets the friction that is stored inside this property holder.
Parameters
- number friction: The coefficient of friction.
SetInertia(number inertia)
This action sets the mass moment of inertia about the about the object's local origin.
Parameters
- number inertia: The mass moment of inertia about the object's local origin.
SetInverseInertia(number inverseInertia)
This action sets the reciprocal of the mass moment of inertia about the object's center of mass.
Parameters
- number inverseInertia: The reciprocal of the mass moment of inertia about the object's center of mass.
SetInverseMass(number inverseMass)
This action sets the reciprocal of the mass (1/mass) inside this property holder without changing mass and density.
Parameters
- number inverseMass: The (1/mass) value.
SetItem(Libraries.Interface.Item2D item)
This action attaches a 2D item, which includes the shape, friction, restitution, positions, and others of a 2D object as a part of the properties that this 2D item has. This action is used internally in the Item2D class when you enable physics on the item when a "PhysicsProperties2D" property holder will be created so that Item2D will be attached to that property holder and the property holder will be attached to the Item2D.
Parameters
- Libraries.Interface.Item2D: The other Item2D to be copied from.
SetLinearDamping(number linearDamping)
This action sets the linear damping inside this property holder.
Parameters
- number linearDamping: The linear damping coefficient.
SetLinearVelocity(Libraries.Compute.Vector2 linearVelocity)
This action sets the linear velocity of the 2D object.
Parameters
- Libraries.Compute.Vector2: The linear velocity of the 2D object.
SetLinearVelocityX(number linearVelocityX)
This action sets the x component of the linear velocity of the 2D object.
Parameters
- number linearVelocityX: The x component of the linear velocity of the 2D object.
SetLinearVelocityY(number linearVelocityY)
This action sets the y component of the linear velocity of the 2D object.
Parameters
- number linearVelocityY: The y component of the linear velocity of the 2D object.
SetMass(number mass)
This action sets the mass of the this property holder, which will also set the density if a 2D item has been attached to this property holder.
Parameters
- number mass: The mass of the object.
SetResponsiveness(integer type)
This action sets how physics (linear velocity, angular velocity, force, torque) will affect the object.
Parameters
- integer type: How physics will affect the object.
SetRestitution(number restitution)
This action sets how much energy that this 3D object will loose after a collision. If you want the object to not loose any energy, then you can pass in 1.0. If you want the object to loose a lot of energy (meaning, they would probably move a lot slower after the collision), then you can pass in a 0.0. You can also use the values between 0 and 1.
Parameters
- number restitution: The coefficient of restitution.
SetSleepTime(number time)
This action sets how much time that the 2D object attached to this property holder will remain in its current position.
Parameters
- number time: How much time that the 2D object attached to this property holder will remain in its current position.
SetTorque(number torque)
This action sets the torque that could potentially be applied to this object.
Parameters
- number torque: The magnitude of torque that could potentially be applied to this object to rotate this object.
Simulate(boolean flag)
This action will change the variables in this property holder based on whether simulation is required of the object that is attached to this property holder. If simulation is not required, then this means that the object's position will not change.
Parameters
- boolean flag: True if you want to simulate the object.
On this page
Variables TableAction Documentation- ApplyAngularImpulse(number impulse)
- ApplyForce(Libraries.Compute.Vector2 force, Libraries.Compute.Vector2 point)
- ApplyForceToCenter(Libraries.Compute.Vector2 force)
- ApplyLinearImpulse(Libraries.Compute.Vector2 impulse, Libraries.Compute.Vector2 point)
- ApplyTorque(number torque)
- AssignMass(number mass)
- CanRotate(boolean flag)
- Compare(Libraries.Language.Object object)
- Copy()
- Equals(Libraries.Language.Object object)
- FastMoving(boolean flag)
- GetAngularDamping()
- GetAngularVelocity()
- GetCollisionGroupFlag()
- GetCollisionGroupIndex()
- GetDensity()
- GetForce()
- GetFriction()
- GetHashCode()
- GetInertia()
- GetInverseInertia()
- GetInverseMass()
- GetItem()
- GetLinearDamping()
- GetLinearVelocity()
- GetMass()
- GetRawInertia()
- GetResponsiveness()
- GetRestitution()
- GetSleepTime()
- GetTorque()
- IsFastMoving()
- IsRotationAllowed()
- IsSimulated()
- IsSimulationRequired()
- RequireSimulation(boolean flag)
- SetAngularDamping(number angularDamping)
- SetAngularVelocity(number angularVelocity)
- SetCollisionGroupFlag(boolean flag)
- SetCollisionGroupIndex(integer index)
- SetDensity(number density)
- SetForce(Libraries.Compute.Vector2 force)
- SetFriction(number friction)
- SetInertia(number inertia)
- SetInverseInertia(number inverseInertia)
- SetInverseMass(number inverseMass)
- SetItem(Libraries.Interface.Item2D item)
- SetLinearDamping(number linearDamping)
- SetLinearVelocity(Libraries.Compute.Vector2 linearVelocity)
- SetLinearVelocityX(number linearVelocityX)
- SetLinearVelocityY(number linearVelocityY)
- SetMass(number mass)
- SetResponsiveness(integer type)
- SetRestitution(number restitution)
- SetSleepTime(number time)
- SetTorque(number torque)
- Simulate(boolean flag)