mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-29 15:30:18 +00:00
ped owner syncvar is assigned before spawning weapon
This commit is contained in:
parent
99ee94229b
commit
8eaf0c956d
3 changed files with 14 additions and 7 deletions
|
@ -155,7 +155,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
}
|
||||
|
||||
|
||||
public static Weapon Create (int modelId)
|
||||
public static Weapon Create (int modelId, Ped initialPedOwner)
|
||||
{
|
||||
NetStatus.ThrowIfNotOnServer();
|
||||
|
||||
|
@ -165,15 +165,20 @@ namespace SanAndreasUnity.Behaviours
|
|||
if (null == go)
|
||||
return null;
|
||||
|
||||
// assign model id before spawning it
|
||||
go.GetComponentOrThrow<NetworkedWeapon>().ModelId = modelId;
|
||||
|
||||
// assign owner ped
|
||||
// asign syncvars before spawning it
|
||||
var networkedWeapon = go.GetComponentOrThrow<NetworkedWeapon>();
|
||||
networkedWeapon.ModelId = modelId;
|
||||
networkedWeapon.PedOwner = initialPedOwner;
|
||||
|
||||
// spawn game object here
|
||||
NetManager.Spawn(go);
|
||||
|
||||
return CreatePart2(go, def, weaponData);
|
||||
Weapon weapon = CreatePart2(go, def, weaponData);
|
||||
|
||||
if (initialPedOwner != null)
|
||||
initialPedOwner.WeaponHolder.AddWeapon(weapon);
|
||||
|
||||
return weapon;
|
||||
}
|
||||
|
||||
static GameObject CreatePart1(int modelId, out WeaponDef def, out WeaponData weaponData)
|
||||
|
|
|
@ -363,7 +363,7 @@ namespace SanAndreasUnity.Behaviours {
|
|||
{
|
||||
NetStatus.ThrowIfNotOnServer();
|
||||
|
||||
this.AddWeapon(Weapon.Create (weaponId));
|
||||
Weapon.Create (weaponId, m_ped);
|
||||
}
|
||||
|
||||
public Weapon GetWeaponAtSlot (int slotIndex)
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
- when (un)hiding weapons, you can't disable their game object
|
||||
|
||||
- add option to remove current weapon - for testing
|
||||
|
||||
|
||||
- **vehicle is bumping on clients** - disable (or destroy) wheel colliders, and sync them - this should not be done on local player, see below
|
||||
|
||||
|
|
Loading…
Reference in a new issue