Manually spawn weapons fixed
Pop the world weapon scene into weaponcontainer
This commit is contained in:
+38
-11
@@ -62,27 +62,54 @@ pickup_radius = 1.5
|
||||
weight = 2.0
|
||||
```
|
||||
|
||||
### Step 3: Create a WorldWeapon Scene (Optional)
|
||||
### Step 3: Spawn Weapons in the Level
|
||||
|
||||
If you want to place weapons in the level:
|
||||
There are two ways to add weapons to your level:
|
||||
|
||||
```
|
||||
[RigidBody3D] - WorldWeaponYourWeapon
|
||||
└─ [CollisionShape3D] - Approximate weapon shape
|
||||
#### Option A: Manual Placement (Recommended)
|
||||
|
||||
1. Open your level scene (e.g., `level/scenes/level.tscn`)
|
||||
2. Drag a WorldWeapon scene into `WeaponsContainer`:
|
||||
- From FileSystem panel: `level/scenes/weapons/world_weapon_sword.tscn`
|
||||
- Or: `level/scenes/weapons/world_weapon_shield.tscn`
|
||||
- Drop it as a child of `WeaponsContainer`
|
||||
3. Position the weapon in 3D space where you want it to spawn
|
||||
4. Save the scene
|
||||
|
||||
**How it works:**
|
||||
- The server automatically detects manually placed WorldWeapon nodes on startup
|
||||
- Each weapon is assigned a unique ID and tracked for multiplayer
|
||||
- Clients automatically receive synced copies via RPC
|
||||
- No code changes needed - just drag and drop!
|
||||
|
||||
#### Option B: Dynamic Spawning
|
||||
|
||||
Spawn weapons via code in `level.gd`:
|
||||
|
||||
```gdscript
|
||||
# In _spawn_initial_weapons() or wherever you need
|
||||
_weapon_spawn_counter += 1
|
||||
rpc("spawn_world_weapon",
|
||||
"res://level/resources/weapon_sword.tres",
|
||||
Vector3(5, 1, 0), # spawn position
|
||||
Vector3.ZERO, # initial velocity
|
||||
_weapon_spawn_counter
|
||||
)
|
||||
```
|
||||
|
||||
Set the script to `world_weapon.gd` and assign your WeaponData resource.
|
||||
|
||||
Example: `level/scenes/weapons/world_weapon_sword.tscn`
|
||||
This is useful for:
|
||||
- Spawning weapons at runtime
|
||||
- Procedural weapon placement
|
||||
- Loot drops from enemies
|
||||
|
||||
## Testing
|
||||
|
||||
### In Godot Editor
|
||||
|
||||
1. Open `level/scenes/level.tscn`
|
||||
2. Drag a WorldWeapon scene (e.g., `world_weapon_sword.tscn`) into the level
|
||||
3. Position it somewhere visible
|
||||
4. Run the game (F5)
|
||||
2. Add a manually placed weapon (see Option A above) or modify `_spawn_initial_weapons()` in `level.gd`
|
||||
3. Run the game (F5)
|
||||
4. Walk near the weapon and press **E** to pick it up
|
||||
|
||||
### Controls
|
||||
|
||||
|
||||
Reference in New Issue
Block a user