Skip to content

Commit b562343

Browse files
update readme for mode
1 parent 408932b commit b562343

File tree

3 files changed

+54
-17
lines changed

3 files changed

+54
-17
lines changed

example/ecctrlClickToMove.png

3.34 MB
Loading

featurelog.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
## New Features
22

3+
### (2024-1-1) EcctrlMode:
4+
5+
- Now you can seamlessly switch between different modes by adding "mode" inside Ecctrl.
6+
7+
`<Ecctrl mode="PointToMove">`
8+
9+
- "PointToMove" mode is designed for click-to-move or path following features. (no needs for keyboard controls)
10+
11+
```js
12+
import { useGame } from 'ecctrl'
13+
// ...
14+
const setMoveToPoint = useGame((state) => state.setMoveToPoint)
15+
// ...
16+
// call function setMoveToPoint(), whenever character needs to move
17+
setMoveToPoint(point) // "point" is a vec3 value
18+
```
19+
20+
- Here is a simple click-to-move example: [Ecctrl CodeSandbox](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh)
21+
22+
[![screenshot](example/ecctrlClickToMove.png)](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh)
23+
324
### (2023-11-18) EcctrlJoystick:
425

526
- Ecctrl now supports touch screen control!

readme.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,26 @@
1313

1414
## New Features
1515

16-
### (2023-11-18) EcctrlJoystick:
16+
### (2024-1-1) EcctrlMode:
1717

18-
- Ecctrl now supports touch screen control!
18+
- Now you can seamlessly switch between different modes by adding "mode" inside Ecctrl.
1919

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)
2223

2324
```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
3131
```
3232

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)
3634

37-
- Also, here is another [Ecctrl CodeSandbox](https://codesandbox.io/s/ecctrl-with-animations-nr4493) showcasing character animation functionality.
38-
39-
[![screenshot](example/ecctrlJoystick.png)](https://codesandbox.io/s/ecctrl-w-o-animations-3k3zxt)
35+
[![screenshot](example/ecctrlClickToMove.png)](https://codesandbox.io/p/sandbox/ecctrl-pointtomove-m9z6xh)
4036

4137
Check out the [featurelog.md](/featurelog.md) for details on previous updates and features.
4238

@@ -174,6 +170,8 @@ EcctrlProps: {
174170
autoBalanceDampingOnY: 0.02, // Auto-balance damping on Y-axis
175171
// Animation temporary setups
176172
animated: false, // Enable animation
173+
// Mode setups
174+
mode: null, // Activate different ecctrl modes
177175
// Other rigibody props from parent
178176
// Rigidbody props can be used here,
179177
// such as position, friction, gravityScale, etc.
@@ -417,6 +415,24 @@ setJoystick(joystickDis, joystickAng, runState);
417415
pressButton1();
418416
```
419417

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+
420436
### (Optional) First-person view setup
421437

422438
If you would like to quickly set up a first-person mode, you can modify these props to achieve that:

0 commit comments

Comments
 (0)