# Using RigidBody¶

## 如何控制刚体¶

A rigid body's behavior can be altered by setting its properties, such as mass and weight. A physics material needs to be added to the rigid body to adjust its friction and bounce, and set if it's absorbent and/or rough. These properties can be set in the Inspector or via code. See RigidBody and PhysicsMaterial for the full list of properties and their effects.

## "look at" 方法¶

```extends RigidBody

func look_follow(state, current_transform, target_position):
var up_dir = Vector3(0, 1, 0)
var cur_dir = current_transform.basis.xform(Vector3(0, 0, 1))
var target_dir = (target_position - current_transform.origin).normalized()
var rotation_angle = acos(cur_dir.x) - acos(target_dir.x)

state.set_angular_velocity(up_dir * (rotation_angle / state.get_step()))

func _integrate_forces(state):
var target_position = \$my_target_spatial_node.get_global_transform().origin
look_follow(state, get_global_transform(), target_position)
```
```class Body : RigidBody
{
private void LookFollow(PhysicsDirectBodyState state, Transform currentTransform, Vector3 targetPosition)
{
var upDir = new Vector3(0, 1, 0);
var curDir = currentTransform.basis.Xform(new Vector3(0, 0, 1));
var targetDir = (targetPosition - currentTransform.origin).Normalized();
var rotationAngle = Mathf.Acos(curDir.x) - Mathf.Acos(targetDir.x);

state.SetAngularVelocity(upDir * (rotationAngle / state.GetStep()));
}

public override void _IntegrateForces(PhysicsDirectBodyState state)
{
var targetPosition = GetNode<Spatial>("my_target_spatial_node").GetGlobalTransform().origin;
LookFollow(state, GetGlobalTransform(), targetPosition);
}
}
```