Members
Methods
accelerate(x, y, z)
Accelerates the body.
Parameters:
Name | Type | Description |
---|---|---|
x |
||
y |
||
z |
addSpeed(speedChange)
Add the provided value to the speed of the body.
Parameters:
Name | Type | Description |
---|---|---|
speedChange |
applyForce(force)
Apply the provided force to the body.
Parameters:
Name | Type | Description |
---|---|---|
force |
attractEachOther(other, magnitudeFactor, minMag, maxMag, cutoffMag)
Applies attraction force to both this and the target body.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
other |
PhysicsBody
|
the other body to interact with | |
magnitudeFactor |
number
|
the factor of magnitude other than the distance | |
minMag |
number
|
0 | the minimum magnitude |
maxMag |
number
|
the maximum magnitude | |
cutoffMag |
number
|
does not apply force if magnitude is smaller than this |
attractToPoint(targetPosition, magnitudeFactor, minMag, maxMag, cutoffMag)
Applies attraction force to this body.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
targetPosition |
p5.Vector
|
the target position | |
magnitudeFactor |
number
|
the factor of magnitude other than the distance | |
minMag |
number
|
0 | the minimum magnitude |
maxMag |
number
|
the maximum magnitude | |
cutoffMag |
number
|
does not apply force if magnitude is smaller than this |
bounce(normalUnitVector, restitution)
(To be filled)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
normalUnitVector |
|||
restitution |
1 |
collides(other)
Returns true if the body collides the provided body.
Parameters:
Name | Type | Description |
---|---|---|
other |
constrainSpeed(maxSpeed)
Constrains the current speed. Should be called every time if needed.
Parameters:
Name | Type | Description |
---|---|---|
maxSpeed |
setFriction(constant)
Sets the friction of the body.
Parameters:
Name | Type | Description |
---|---|---|
constant |