건설 시스템 기초 생성 및 Kaykit Medival 애셋 추가
This commit is contained in:
128
INPUT_ACTIONS_SETUP.md
Normal file
128
INPUT_ACTIONS_SETUP.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Building System Input Actions Setup
|
||||
|
||||
## Required Input Actions
|
||||
|
||||
Add these three actions to your `InputSystem_Actions.inputactions` file in the **Player** action map:
|
||||
|
||||
### 1. ToggleBuildMode (Button)
|
||||
- **Action Type**: Button
|
||||
- **Control Type**: Button
|
||||
- **Binding**: Keyboard B
|
||||
|
||||
### 2. Rotate (Value)
|
||||
- **Action Type**: Value
|
||||
- **Control Type**: Axis
|
||||
- **Binding**: Keyboard R (positive value)
|
||||
- Alternative: You can use a 1D Axis composite with:
|
||||
- Negative: Q
|
||||
- Positive: E
|
||||
|
||||
### 3. Build (Button)
|
||||
- **Action Type**: Button
|
||||
- **Control Type**: Button
|
||||
- **Binding**: Mouse Left Button
|
||||
|
||||
## Step-by-Step Setup in Unity
|
||||
|
||||
1. **Open Input Actions Asset**
|
||||
- Navigate to `Assets/InputSystem_Actions.inputactions`
|
||||
- Double-click to open the Input Actions window
|
||||
|
||||
2. **Select Player Action Map**
|
||||
- In the left panel, click on "Player" action map
|
||||
|
||||
3. **Add ToggleBuildMode Action**
|
||||
- Click the "+" button in the Actions column
|
||||
- Name it: `ToggleBuildMode`
|
||||
- Action Type: Button
|
||||
- Add binding: Keyboard → B
|
||||
|
||||
4. **Add Rotate Action**
|
||||
- Click the "+" button in the Actions column
|
||||
- Name it: `Rotate`
|
||||
- Action Type: Value
|
||||
- Control Type: Axis
|
||||
|
||||
**Option A (Simple - Single key):**
|
||||
- Add binding: Keyboard → R
|
||||
|
||||
**Option B (Advanced - Q/E rotation):**
|
||||
- Right-click → Add 1D Axis Composite
|
||||
- Negative: Keyboard → Q
|
||||
- Positive: Keyboard → E
|
||||
|
||||
5. **Add Build Action**
|
||||
- Click the "+" button in the Actions column
|
||||
- Name it: `Build`
|
||||
- Action Type: Button
|
||||
- Add binding: Mouse → Left Button
|
||||
|
||||
6. **Save and Regenerate**
|
||||
- Click "Save Asset" button
|
||||
- The `InputSystem_Actions.cs` script will auto-regenerate
|
||||
|
||||
## How It Works in Code
|
||||
|
||||
The BuildingPlacement script subscribes to these actions:
|
||||
|
||||
```csharp
|
||||
// Setup in OnNetworkSpawn
|
||||
_inputActions.Player.ToggleBuildMode.performed += OnToggleBuildMode;
|
||||
_inputActions.Player.Rotate.performed += OnRotate;
|
||||
_inputActions.Player.Build.performed += OnBuild;
|
||||
|
||||
// Cleanup in OnNetworkDespawn
|
||||
_inputActions.Player.ToggleBuildMode.performed -= OnToggleBuildMode;
|
||||
_inputActions.Player.Rotate.performed -= OnRotate;
|
||||
_inputActions.Player.Build.performed -= OnBuild;
|
||||
```
|
||||
|
||||
### ToggleBuildMode
|
||||
- Triggers when B is pressed
|
||||
- Toggles build mode on/off
|
||||
- Shows/hides building preview
|
||||
|
||||
### Rotate
|
||||
- Triggers when R is pressed (or Q/E if using composite)
|
||||
- Reads value: positive = rotate right, negative = rotate left
|
||||
- Rotates building preview by 90°
|
||||
|
||||
### Build
|
||||
- Triggers when left mouse button is pressed
|
||||
- Only works when build mode is active
|
||||
- Places the building at the preview position
|
||||
|
||||
## Customizing Controls
|
||||
|
||||
To change the key bindings:
|
||||
1. Open `InputSystem_Actions.inputactions`
|
||||
2. Click on the binding you want to change
|
||||
3. Click "Path" dropdown
|
||||
4. Select new key/button
|
||||
5. Save Asset
|
||||
|
||||
No code changes needed - the script uses the action names, not specific keys!
|
||||
|
||||
## Testing
|
||||
|
||||
After setup:
|
||||
1. Enter Play mode
|
||||
2. Press **B** → Should see "Entered Build Mode" in console
|
||||
3. Press **R** → Building preview should rotate
|
||||
4. Click **Left Mouse Button** → Should place building (if valid position)
|
||||
5. Press **B** again → Should exit build mode
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Error: "ToggleBuildMode does not exist"**
|
||||
- Make sure you named the action exactly `ToggleBuildMode` (case-sensitive)
|
||||
- Save the Input Actions asset to regenerate the code
|
||||
|
||||
**Rotation doesn't work:**
|
||||
- Check the action name is exactly `Rotate`
|
||||
- If using composite, make sure it's a 1D Axis composite
|
||||
- Verify the action type is "Value" not "Button"
|
||||
|
||||
**Build action triggers during movement:**
|
||||
- Make sure Build action is mapped to Mouse Left Button, not Attack
|
||||
- Check that Build mode is active (press B first)
|
||||
Reference in New Issue
Block a user