Skip to content

Commit

Permalink
Merge pull request #2294 from galacean/doc/fix-syntax
Browse files Browse the repository at this point in the history
fix: fix markdown syntax
  • Loading branch information
MrKou47 authored Aug 2, 2024
2 parents bd96bb3 + 6531108 commit dc05369
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/en/physics/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Like collider components, a `ColliderShape` is constructed and added to the comp
2. Currently, character controllers only support `CapsuleColliderShape` and `BoxColliderShape`, with `CapsuleColliderShape` being the most commonly used.

The behavior of the character controller can be controlled through the parameters and methods of `CharacterController`, with the most important one being the `move` function:

```typescript
class Controller extends Script {
onPhysicsUpdate() {
Expand All @@ -32,9 +33,10 @@ class Controller extends Script {
this._displacement.setValue(0, 0, 0);
}
}
````
```

In the `move` method, you can specify the character's displacement, and this method returns an enum type composite value. By using the enum type `ControllerCollisionFlag`, you can determine if the character controller collides with other collider components:

```typescript
export enum ControllerCollisionFlag {
/** Character is colliding to the sides. */
Expand All @@ -45,5 +47,7 @@ export enum ControllerCollisionFlag {
Down = 4
}
```

Based on this, the character's subsequent animations and movements can be determined. In the example below, you can control the character's movement using the keyboard to make it climb or jump over specific obstacles.

<playground src="physx-controller.ts"></playground>
6 changes: 5 additions & 1 deletion docs/zh/physics/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ characterController.addShape(physicsCapsule);
2. 角色控制器目前只支持 `CapsuleColliderShape``BoxColliderShape`,且其中 `CapsuleColliderShape` 最为常用。

后续角色控制器的行为通过 `CharacterController` 的各个参数和方法进行控制,其中最重要的是 `move` 函数:

```typescript
class Controller extends Script {
onPhysicsUpdate() {
Expand All @@ -32,9 +33,10 @@ class Controller extends Script {
this._displacement.setValue(0, 0, 0);
}
}
````
```

可以在 `move` 方法中指定角色位移,并且该方法返回一个枚举类型的复合值,通过该枚举类型 `ControllerCollisionFlag` 可以判断角色控制器是否碰到其他的碰撞器组件:

```typescript
export enum ControllerCollisionFlag {
/** Character is colliding to the sides. */
Expand All @@ -45,5 +47,7 @@ export enum ControllerCollisionFlag {
Down = 4
}
```

由此角色接下来的动画和运动要怎么进行。在下面的例子当中,可以通过键盘控制角色的运动,使其爬上或者跳过特定的障碍物。

<playground src="physx-controller.ts"></playground>

0 comments on commit dc05369

Please sign in to comment.