Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Public Attributes | List of all members
VerletPhysics.GravityBehavior Class Reference

Gravity behavior. More...

Inheritance diagram for VerletPhysics.GravityBehavior:
VerletPhysics.IBehavior

Public Member Functions

 GravityBehavior (Vector2? gravity=null)
 Create a gravity behavior. More...
 
void ApplyBehavior (VerletPoint point, float delta)
 Apply behavior to a verlet point. More...
 

Public Attributes

Vector2 Gravity = new Vector2(0, 9.81f)
 Gravity value More...
 

Detailed Description

Gravity behavior.

Definition at line 8 of file GravityBehavior.cs.

Constructor & Destructor Documentation

◆ GravityBehavior()

VerletPhysics.GravityBehavior.GravityBehavior ( Vector2?  gravity = null)
inline

Create a gravity behavior.

Parameters
gravityGravity value

Definition at line 17 of file GravityBehavior.cs.

18  {
19  Gravity = gravity ?? Gravity;
20  }
Vector2 Gravity
Gravity value

Member Function Documentation

◆ ApplyBehavior()

void VerletPhysics.GravityBehavior.ApplyBehavior ( VerletPoint  point,
float  delta 
)
inline

Apply behavior to a verlet point.

Parameters
pointVerlet point
deltaDelta time

Implements VerletPhysics.IBehavior.

Definition at line 22 of file GravityBehavior.cs.

23  {
24  if (!point.Touched)
25  {
26  point.ApplyForce(Gravity * point.GravityScale);
27  }
28  }

Member Data Documentation

◆ Gravity

Vector2 VerletPhysics.GravityBehavior.Gravity = new Vector2(0, 9.81f)

Gravity value

Definition at line 11 of file GravityBehavior.cs.


The documentation for this class was generated from the following file: