Difference between revisions of "Fixture:setRestitution"

m
(summarize how Restitution works, it's range, and reference the implementation)
 
Line 1: Line 1:
 
{{newin|[[0.8.0]]|080|type=method}}
 
{{newin|[[0.8.0]]|080|type=method}}
Sets the restitution of the fixture.
+
Sets the restitution of the fixture. '''Range''': [0.0, 1.0]
 +
 
 +
Restitution determines how much a body bounces after a collision. The value should be greater than zero and is usually in [0, 1].
 +
 
 +
You can think of restitution as a scale on the reflected velocity after a collision. A bouncy ball would have a high restitution (an elastic collision keeps most of the velocity) and a brick a low restitution (inelastic collision loses most of the velocity). A value of one would be perfectly elastic and maintain all of its velocity.
 +
 
 +
For more detail, see how [https://github.com/love2d/love/blob/977c690fa97760ed195d2e32570a7ac8eb19318b/src/libraries/Box2D/Dynamics/Contacts/b2ContactSolver.cpp#L208-L214 Box2D's ContactSolver uses restitution to scale the velocityBias] and [https://github.com/love2d/love/blob/977c690fa97760ed195d2e32570a7ac8eb19318b/src/libraries/Box2D/Dynamics/Contacts/b2Contact.h#L42-L47 how it preserves the higher restitution of two bodies] to bias towards bounciness.
 +
 
  
 
== Function ==
 
== Function ==

Latest revision as of 00:54, 28 June 2021

Available since LÖVE 0.8.0
This method is not supported in earlier versions.

Sets the restitution of the fixture. Range: [0.0, 1.0]

Restitution determines how much a body bounces after a collision. The value should be greater than zero and is usually in [0, 1].

You can think of restitution as a scale on the reflected velocity after a collision. A bouncy ball would have a high restitution (an elastic collision keeps most of the velocity) and a brick a low restitution (inelastic collision loses most of the velocity). A value of one would be perfectly elastic and maintain all of its velocity.

For more detail, see how Box2D's ContactSolver uses restitution to scale the velocityBias and how it preserves the higher restitution of two bodies to bias towards bounciness.


Function

Synopsis

Fixture:setRestitution( restitution )

Arguments

number restitution
The fixture restitution.

Returns

Nothing.

See Also


Other Languages