JointSuspension Class
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits from: | Joint |
This joint type is deprecated and will be removed in the upcoming releases. It is recommended to use the Wheel Joint instead.
This class is used to create a suspension joint. The bodies that represent both a frame and a wheel must be rigid bodies.
Example#
The following code illustrates connection of two rigid bodies (frame and wheel) using a suspension joint.
JointSuspension joint = class_remove(new JointSuspension(frame, wheel));
// setting joint anchor coordinates
joint.setWorldAnchor(wheel.getObject().getWorldTransform() * Vec3_zero);
// setting joint axes coordinates
joint.setWorldAxis0(vec3(0.0f,0.0f,1.0f));
joint.setWorldAxis1(vec3(0.0f,1.0f,0.0f));
// setting linear damping and spring rigidity
joint.setLinearDamping(2.0f);
joint.setLinearSpring(200.0f);
// setting lower and upper suspension ride limits [-0.5; 0.0]
joint.setLinearLimitFrom(-0.5f);
joint.setLinearLimitTo(0.0f);
// setting target suspension height
joint.setLinearDistance(0.5f);
// setting maximum angular velocity and torque
joint.setAngularVelocity(-20.0f);
joint.setAngularTorque(10.0f);
// setting common joint constraint parameters
joint.setLinearRestitution(0.2f);
joint.setAngularRestitution(0.2f);
joint.setLinearSoftness(0.2f);
joint.setAngularSoftness(0.2f);
// setting number of iterations
joint.setNumIterations(8);
See Also#
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/physics/ folder:
- car_00
- car_01
- car_03
JointSuspension Class
Members
static JointSuspension ( ) #
Constructor. Creates a suspension joint with an anchor at the origin of the world coordinates.static JointSuspension ( Body body0, Body body1 ) #
Constructor. Creates a suspension joint connecting two given bodies. An anchor is placed between centers of mass of the bodies.Arguments
- Body body0 - Frame to be connected with the joint.
- Body body1 - Wheel to be connected with the joint.
static JointSuspension ( Body body0, Body body1, Vec3 anchor, vec3 axis0, vec3 axis1 ) #
Constructor. Creates a suspension joint connecting two given bodies with specified suspension and spindle axis coordinates and an anchor placed at specified coordinates.Arguments
- Body body0 - Frame to be connected with the joint.
- Body body1 - Wheel to be connected with the joint.
- Vec3 anchor - Anchor coordinates.
- vec3 axis0 - Suspension axis coordinates.
- vec3 axis1 - Wheel spindle axis coordinates.
void setAngularDamping ( float damping ) #
Sets an angular damping of the joint (wheel rotation damping).Arguments
- float damping - Angular damping. If a negative value is provided, 0 will be used instead.
float getAngularDamping ( ) #
Returns the angular damping of the joint (wheel rotation damping).Return value
Angular damping.void setAngularTorque ( float torque ) #
Sets a maximum torque of the attached angular motor.Arguments
- float torque - Maximum torque. If a negative value is provided, 0 will be used instead.
float getAngularTorque ( ) #
Returns the maximum torque of the attached angular motor.Return value
Maximum torque.void setAngularVelocity ( float velocity ) #
Sets a maximum velocity of wheel rotation.Arguments
- float velocity - Velocity in radians per second.
float getAngularVelocity ( ) #
Returns the target velocity of wheel rotation.Return value
Target velocity in radians per second.void setAxis00 ( vec3 axis00 ) #
Sets coordinates of suspension axis, along which a wheel moves vertically. This is a shock absorber.Arguments
- vec3 axis00 - Suspension axis.
vec3 getAxis00 ( ) #
Returns suspension axis coordinates.Return value
Suspension axis.void setAxis10 ( vec3 axis10 ) #
Sets a wheel spindle axis in coordinates of the frame (body 0): an axis around which a wheel rotates when moving forward (or backward).
Arguments
- vec3 axis10 - Wheel spindle axis in coordinates of the frame (body 0).
vec3 getAxis10 ( ) #
Returns the wheel spindle axis in coordinates of the frame (body 0).
Return value
Wheel spindle axis in coordinates of the frame (body 0).void setAxis11 ( vec3 axis11 ) #
Sets a wheel spindle axis in coordinates of the wheel (body 1): an axis around which a wheel rotates when steering.
Arguments
- vec3 axis11 - Wheel spindle axis in coordinates of the wheel (body 1).
vec3 getAxis11 ( ) #
Returns the wheel spindle in coordinates of the wheel (body 1).
Return value
Wheel spindle axis in coordinates of the wheel (body 1).float getCurrentAngularVelocity ( ) #
Returns the current velocity of wheel rotation.Return value
Current velocity in radians per second.float getCurrentLinearDistance ( ) #
Returns the current suspension compression.Return value
Current suspension height in units.void setLinearDamping ( float damping ) #
Sets a linear damping of the suspension.Arguments
- float damping - Linear damping. If a negative value is provided, 0 will be used instead.
float getLinearDamping ( ) #
Returns the linear damping of the suspension.Return value
Linear damping.void setLinearDistance ( float distance ) #
Sets a target height of the suspension.Arguments
- float distance - Height in units.
float getLinearDistance ( ) #
Returns the target height of the suspension.Return value
Target height in units.void setLinearLimitFrom ( float from ) #
Sets a low limit of the suspension ride.Arguments
- float from - Limit in units.
float getLinearLimitFrom ( ) #
Returns the low limit of the suspension ride.Return value
Low limit in units.void setLinearLimitTo ( float to ) #
Sets a high limit of the suspension ride.Arguments
- float to - Limit in units.
float getLinearLimitTo ( ) #
Returns the high limit of the suspension ride.Return value
High limit in units.void setLinearSpring ( float spring ) #
Sets a rigidity coefficient of the suspension.Arguments
- float spring - Rigidity coefficient. If a negative value is provided, 0 will be used instead.
float getLinearSpring ( ) #
Returns the rigidity coefficient of the suspension.Return value
Rigidity coefficient.void setWorldAxis0 ( vec3 axis0 ) #
Sets suspension axis in the world coordinates.Arguments
- vec3 axis0 - Suspension axis in the world coordinates.
vec3 getWorldAxis0 ( ) #
Returns the suspension axis in the world coordinates.Return value
Suspension axis in the world coordinates.void setWorldAxis1 ( vec3 axis1 ) #
Sets a wheel spindle axis in the world coordinates.Arguments
- vec3 axis1 - Wheel spindle axis in the world coordinates.
vec3 getWorldAxis1 ( ) #
Returns the wheel spindle axis in the world coordinates.Return value
Wheel spindle axis in the world coordinates.Last update:
2021-12-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)