possibility of having multiple clips in the knife attack?

Support for MFPS 2.0 (for verified users)
Forum rules
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
Post Reply
User avatar
Maxime66410
New Member
New Member
Posts: 3
Joined: Tue Dec 01, 2020 9:53 am

Hello, I've been trying to figure out how to make sure that when we attack with a knife the player makes several random noise.

Because currently it is a system where there is only a single clip, except that I would like to use an array to have multiple clips and therefore play a random clip when the player hits with the weapon.

I already tried to modify all this.

In "bl_Gun"

Line 18 :

Code: Select all

public AudioClip FireSound;
to

Code: Select all

public AudioClip[] FireSound;
Line 1081 to 1087 :

Code: Select all

if (Info.Type != GunType.Grenade)
        {
            Source.clip = FireSound;
            Source.spread = Random.Range(1.0f, 1.5f);
            Source.Play();
        }
  }
To

Code: Select all

        if (Info.Type != GunType.Grenade)
        {
            FireRandomSounds();
        }
   }
Line 1143 to 1150 :

Code: Select all

public void PlayFireAudio()
    {
        FireSource.clip = FireSound;
        FireSource.spread = Random.Range(1.0f, 1.5f);
        FireSource.pitch = Random.Range(1.0f, 1.075f);
        FireSource.Play();
    }
To

Code: Select all

public void PlayFireAudio()
    {
        FireRandomSounds();
    }

New line in 1689 (This kind of system works very well.) :

Code: Select all

    public void FireRandomSounds()
    {
        FireSource.clip = FireSound[Random.Range(0, FireSound.Length)];
        FireSource.Play();
    } 

In "bl_NetworkGun"

Line 121 to 123 :

Code: Select all

            Source.clip = LocalGun.FireSound;
            Source.spread = Random.Range(1.0f, 1.5f);
            Source.Play();
          
To

Code: Select all

           LocalGun.FireRandomSounds();
Line 131 to 141 :

Code: Select all

public void KnifeFire()
    {
        if (LocalGun != null)
        {
            Source.clip = LocalGun.FireSound;
            Source.spread = Random.Range(1.0f, 1.5f);
            Source.Play();
        }
    }
To

Code: Select all

public void KnifeFire()
    {
        if (LocalGun != null)
        {
            LocalGun.FireRandomSounds();
        }
    }

Line 165 to 171 :

Code: Select all

public void PlayLocalFireAudio()
    {
        Source.clip = LocalGun.FireSound;
        Source.spread = Random.Range(1.0f, 1.5f);
        Source.Play();
    }
To

Code: Select all

    public void PlayLocalFireAudio()
    {
        LocalGun.FireRandomSounds();
    }

In "bl_GunEditor"

Error line 178 :

Code: Select all

script.FireSound = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
Error line 372 :

Code: Select all

script.FireSound = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
Is same error.

List of errors :

Code: Select all

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(178,60): error CS1503: Argument 1: cannot convert from 'string' to 'UnityEngine.Object'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(178,74): error CS1503: Argument 2: cannot convert from 'UnityEngine.AudioClip[]' to 'System.Type'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(178,92): error CS1503: Argument 3: cannot convert from 'System.Type' to 'UnityEngine.GUILayoutOption'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(178,123): error CS1503: Argument 4: cannot convert from 'bool' to 'UnityEngine.GUILayoutOption'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(372,56): error CS1503: Argument 1: cannot convert from 'string' to 'UnityEngine.Object'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(372,70): error CS1503: Argument 2: cannot convert from 'UnityEngine.AudioClip[]' to 'System.Type'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(372,88): error CS1503: Argument 3: cannot convert from 'System.Type' to 'UnityEngine.GUILayoutOption'

Assets\MFPS\Scripts\Internal\Editor\MFPS\bl_GunEditor.cs(372,119): error CS1503: Argument 4: cannot convert from 'bool' to 'UnityEngine.GUILayoutOption'

Did you have an alternative for me or how to correct it?

Thanks for your help !
Sanchez
Post Reply