---
title: "linearGravityField(withVector:)"
framework: spritekit
role: symbol
role_heading: Type Method
path: "spritekit/skfieldnode/lineargravityfield(withvector:)"
---

# linearGravityField(withVector:)

Creates a field node that accelerates physics bodies in a specific direction.

## Declaration

```swift
class func linearGravityField(withVector direction: vector_float3) -> SKFieldNode
```

## Parameters

- `direction`: The direction and magnitude of the gravitational force. The values represent the acceleration of the field in meters per second squared. For example, to simulate earth’s gravity, specify (0, -9.8, 0). The z component on the vector is ignored.

## Return Value

Return Value A new linear gravity field node.

## Discussion

Discussion If the field node is rotated, the direction of its gravity field is also rotated. The calculated force is proportional to the physics body’s mass (meaning that the acceleration applied to all affected physics bodies is a constant).

## See Also

### Creating Field Nodes

- [dragField()](spritekit/skfieldnode/dragfield().md)
- [electricField()](spritekit/skfieldnode/electricfield().md)
- [magneticField()](spritekit/skfieldnode/magneticfield().md)
- [noiseField(withSmoothness:animationSpeed:)](spritekit/skfieldnode/noisefield(withsmoothness:animationspeed:).md)
- [radialGravityField()](spritekit/skfieldnode/radialgravityfield().md)
- [springField()](spritekit/skfieldnode/springfield().md)
- [turbulenceField(withSmoothness:animationSpeed:)](spritekit/skfieldnode/turbulencefield(withsmoothness:animationspeed:).md)
- [velocityField(with:)](spritekit/skfieldnode/velocityfield(with:).md)
- [velocityField(withVector:)](spritekit/skfieldnode/velocityfield(withvector:).md)
- [vortexField()](spritekit/skfieldnode/vortexfield().md)
- [customField(evaluationBlock:)](spritekit/skfieldnode/customfield(evaluationblock:).md)
- [SKFieldForceEvaluator](spritekit/skfieldforceevaluator.md)
