|
13 | 13 |
|
14 | 14 | ## New Features
|
15 | 15 |
|
16 |
| -### (2023-11-18) EcctrlJoystick: |
| 16 | +### (2024-1-1) EcctrlMode: |
17 | 17 |
|
18 |
| -- Ecctrl now supports touch screen control! |
| 18 | +- Now you can seamlessly switch between different modes by adding "mode" inside Ecctrl. |
19 | 19 |
|
20 |
| -- You can easily import and use the built-in 3D joystick. |
21 |
| - (note: place EcctrlJoystick outside of the canvas component) |
| 20 | +`<Ecctrl mode="PointToMove">` |
| 21 | + |
| 22 | +- "PointToMove" mode is designed for click-to-move or path following features. (no needs for keyboard controls) |
22 | 23 |
|
23 | 24 | ```js
|
24 |
| -import Ecctrl, {EcctrlJoystick} from 'ecctrl' |
25 |
| -//... |
26 |
| - <EcctrlJoystick /> |
27 |
| - <Canvas> |
28 |
| - {/* ... */} |
29 |
| - </Canvas> |
30 |
| -//... |
| 25 | +import { useGame } from 'ecctrl' |
| 26 | +// ... |
| 27 | +const setMoveToPoint = useGame((state) => state.setMoveToPoint) |
| 28 | +// ... |
| 29 | +// call function setMoveToPoint(), whenever character needs to move |
| 30 | +setMoveToPoint(point) // "point" is a vec3 value |
31 | 31 | ```
|
32 | 32 |
|
33 |
| -- For more detailed settings, including lights, materials, and textures, please refer to the following sections. |
34 |
| - |
35 |
| -- Additionally, I've prepared a simple [Ecctrl CodeSandbox](https://codesandbox.io/s/ecctrl-w-o-animations-3k3zxt) for online testing and demostration. |
| 33 | +- Here is a simple click-to-move example: [Ecctrl CodeSandbox](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh) |
36 | 34 |
|
37 |
| -- Also, here is another [Ecctrl CodeSandbox](https://codesandbox.io/s/ecctrl-with-animations-nr4493) showcasing character animation functionality. |
38 |
| - |
39 |
| -[](https://codesandbox.io/s/ecctrl-w-o-animations-3k3zxt) |
| 35 | +[](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh) |
40 | 36 |
|
41 | 37 | Check out the [featurelog.md](/featurelog.md) for details on previous updates and features.
|
42 | 38 |
|
@@ -174,6 +170,8 @@ EcctrlProps: {
|
174 | 170 | autoBalanceDampingOnY: 0.02, // Auto-balance damping on Y-axis
|
175 | 171 | // Animation temporary setups
|
176 | 172 | animated: false, // Enable animation
|
| 173 | + // Mode setups |
| 174 | + mode: null, // Activate different ecctrl modes |
177 | 175 | // Other rigibody props from parent
|
178 | 176 | // Rigidbody props can be used here,
|
179 | 177 | // such as position, friction, gravityScale, etc.
|
@@ -417,6 +415,24 @@ setJoystick(joystickDis, joystickAng, runState);
|
417 | 415 | pressButton1();
|
418 | 416 | ```
|
419 | 417 |
|
| 418 | +### Ecctrl Mode |
| 419 | + |
| 420 | +Activate different modes in Ecctrl by including the desired mode inside Ecctrl component: |
| 421 | +`<Ecctrl mode="PointToMove">`. |
| 422 | + |
| 423 | +#### 1. "PointToMove" Mode ([CodeSandbox Demo](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh?file=%2Fsrc%2FMap.js%3A46%2C19)) |
| 424 | + |
| 425 | +This mode doesn't require keyboard controls and is designed for click-to-move or path-following features. |
| 426 | + |
| 427 | +```js |
| 428 | +import { useGame } from 'ecctrl' |
| 429 | +// ... |
| 430 | +const setMoveToPoint = useGame((state) => state.setMoveToPoint) |
| 431 | +// ... |
| 432 | +// call function setMoveToPoint(), whenever character needs to move |
| 433 | +setMoveToPoint(point) // "point" is a vec3 value |
| 434 | +``` |
| 435 | + |
420 | 436 | ### (Optional) First-person view setup
|
421 | 437 |
|
422 | 438 | If you would like to quickly set up a first-person mode, you can modify these props to achieve that:
|
|
0 commit comments