![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Used in the Soft Collider.prefab, which is put as a child onto other objects. Allows for other objects to pass through this object, but push them out if they stay inside this object.
For example, a player can pass through a pot or an enemy, but will be pushed away if they try to stand inside it. Think of how animals in Minecraft push each other around when there's too many in a small area.
Documentation updated 9/15/2024
Properties | |
Rigidbody2D | ParentBody [get, set] |
Reference to the rigidbody of the parent object. | |
Private Member Functions | |||
void | OnTriggerEnter2D (Collider2D collision) | ||
Runs when an object enters the soft collider. Adds any new opposing colliders to the opposingColliders list.
| |||
void | OnTriggerStay2D (Collider2D collision) | ||
Runs every frame an object is in the soft collider. Calculate and apply momentum to each object in opposingColliders that pushes them away from this object.
| |||
void | OnTriggerExit2D (Collider2D collision) | ||
Runs when an object exits the soft collider. Remove any leaving opposing colliders from the opposingColliders list.
| |||
void | Awake () | ||
Initialize ParentBody and opposingColliders. | |||
Private Attributes | |
List< SoftCollider > | opposingColliders |
List of all objects colliding with the parent object. | |
float | pushMagnitude = 3f |
How much the opposing colliders should be pushed away. | |
|
private |
Initialize ParentBody and opposingColliders.
|
private |
Runs when an object enters the soft collider. Adds any new opposing colliders to the opposingColliders list.
collision |
|
private |
Runs when an object exits the soft collider. Remove any leaving opposing colliders from the opposingColliders list.
collision |
|
private |
Runs every frame an object is in the soft collider. Calculate and apply momentum to each object in opposingColliders that pushes them away from this object.
collision | Represents the object colliding with the SoftCollider hitbox. |
|
private |
List of all objects colliding with the parent object.
|
private |
How much the opposing colliders should be pushed away.
|
getset |
Reference to the rigidbody of the parent object.