Added sounds to player scripts
This commit is contained in:
parent
66211085cb
commit
b924890951
@ -13,12 +13,14 @@ GameObject:
|
||||
- component: {fileID: 1772573266731274169}
|
||||
- component: {fileID: 1772573266731274174}
|
||||
- component: {fileID: 1772573266731274173}
|
||||
- component: {fileID: 1772573266731274172}
|
||||
- component: {fileID: 1772573266731274163}
|
||||
- component: {fileID: 8474203461765366282}
|
||||
- component: {fileID: 8078848171855759243}
|
||||
- component: {fileID: 1772573266731274172}
|
||||
- component: {fileID: 1447597341752185403}
|
||||
- component: {fileID: 1211811550}
|
||||
- component: {fileID: 1211811541}
|
||||
- component: {fileID: 2761483155973167578}
|
||||
m_Layer: 8
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@ -108,7 +110,7 @@ Rigidbody:
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 8
|
||||
m_Constraints: 120
|
||||
m_CollisionDetection: 2
|
||||
--- !u!114 &1772573266731274173
|
||||
MonoBehaviour:
|
||||
@ -122,6 +124,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 5f45bd04209bb424e8b1f5271cb16ab0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
soundPlayer: {fileID: 8078848171855759243}
|
||||
maxGrappleDist: 15
|
||||
grappleExtensionSpeed: 2.5
|
||||
grappleStrength: 40
|
||||
@ -135,6 +138,59 @@ MonoBehaviour:
|
||||
gunPos: {fileID: 1772573266917019329}
|
||||
canvasRect: {fileID: 0}
|
||||
hitMarkerRect: {fileID: 0}
|
||||
--- !u!114 &1772573266731274163
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 60e46f6febb0d4a4592dd894365ffeb2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rb: {fileID: 1772573266731274174}
|
||||
soundPlayer: {fileID: 8078848171855759243}
|
||||
canWalk: 1
|
||||
canJump: 1
|
||||
movementSpeed: 0.8
|
||||
maxMovementSpeed: 28
|
||||
jumpPower: 3
|
||||
afterJumpHorizontalSlowdownTime: 1
|
||||
groundDrag: 1
|
||||
airDrag: 0
|
||||
playerHeight: 0.6
|
||||
jumpAirSlowdown: 80
|
||||
groundHitSoundVelocity: 24
|
||||
grappleHook: {fileID: 1772573266731274173}
|
||||
isGrounded: 0
|
||||
--- !u!114 &8474203461765366282
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9b5fa9960655cb742880ef94db81ca9c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
soundPlayer: {fileID: 8078848171855759243}
|
||||
--- !u!114 &8078848171855759243
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6fb36fee47a0d6a44bc2237dfbdac4d5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
playableSounds: []
|
||||
--- !u!114 &1772573266731274172
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -262,43 +318,6 @@ MonoBehaviour:
|
||||
m_DefaultActionMap: Player
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
--- !u!114 &1772573266731274163
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 60e46f6febb0d4a4592dd894365ffeb2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rb: {fileID: 1772573266731274174}
|
||||
canWalk: 1
|
||||
canJump: 1
|
||||
movementSpeed: 0.8
|
||||
maxMovementSpeed: 30
|
||||
jumpPower: 3
|
||||
afterJumpHorizontalSlowdownTime: 1
|
||||
groundDrag: 1
|
||||
airDrag: 0
|
||||
playerHeight: 0.6
|
||||
jumpAirSlowdown: 80
|
||||
grappleHook: {fileID: 1772573266731274173}
|
||||
isGrounded: 0
|
||||
--- !u!114 &8474203461765366282
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9b5fa9960655cb742880ef94db81ca9c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!136 &1447597341752185403
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -347,6 +366,102 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_startsRagdolled: 1
|
||||
_hipBone: {fileID: 2527212996625801578}
|
||||
--- !u!82 &2761483155973167578
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772573266731274171}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &1772573266864950258
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -2,10 +2,12 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Bytes.Sound;
|
||||
|
||||
public class CharacterMovement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody rb;
|
||||
[SerializeField] private SoundPlayer soundPlayer;
|
||||
|
||||
[Header("Enable switches")]
|
||||
[SerializeField] private bool canWalk;
|
||||
@ -22,9 +24,11 @@ public class CharacterMovement : MonoBehaviour
|
||||
[SerializeField] private float airDrag;
|
||||
[SerializeField] private float playerHeight;
|
||||
[SerializeField] private float jumpAirSlowdown;
|
||||
[SerializeField] private float groundHitSoundVelocity;
|
||||
[SerializeField] private GrappleHook grappleHook;
|
||||
public bool isGrounded;
|
||||
private bool isStunned = false;
|
||||
private bool canHitGround = true;
|
||||
|
||||
private Vector3 rawInputMovement;
|
||||
private float afterJumpHorizontalSlowdownTimeCounter;
|
||||
@ -146,4 +150,21 @@ public class CharacterMovement : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if(rb.velocity.magnitude>= groundHitSoundVelocity && canHitGround)
|
||||
{
|
||||
soundPlayer.PlaySound("PlayerGroudHit");
|
||||
StartCoroutine(DelayGroundHit(.2f));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator DelayGroundHit(float delay)
|
||||
{
|
||||
canHitGround = false;
|
||||
yield return new WaitForSeconds(delay);
|
||||
canHitGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,11 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.InputSystem;
|
||||
using Bytes.Sound;
|
||||
|
||||
public class GrappleHook : MonoBehaviour
|
||||
{
|
||||
[SerializeField] SoundPlayer soundPlayer;
|
||||
|
||||
[Header("Grapple settings")]
|
||||
[SerializeField]
|
||||
@ -120,6 +122,8 @@ public class GrappleHook : MonoBehaviour
|
||||
grappled = true;
|
||||
grappling = false;
|
||||
|
||||
soundPlayer.PlaySound("PlayerGrappleHit");
|
||||
|
||||
//Display
|
||||
hitMarkerRect.gameObject.SetActive(false);
|
||||
|
||||
@ -150,6 +154,10 @@ public class GrappleHook : MonoBehaviour
|
||||
}
|
||||
|
||||
private void EndGrapple(){
|
||||
if (grappled)
|
||||
{
|
||||
soundPlayer.PlaySound("PlayerGrappleDetach");
|
||||
}
|
||||
grappled = false;
|
||||
grappling = false;
|
||||
lr.enabled = false;
|
||||
@ -195,14 +203,17 @@ public void Unhook(GameObject hookedObj){
|
||||
if(grappling && grappled)return;
|
||||
if(context.performed){
|
||||
grappling = true;
|
||||
}else if(context.canceled){
|
||||
soundPlayer.PlaySound("PlayerGrappleFire");
|
||||
}
|
||||
else if(context.canceled){
|
||||
EndGrapple();
|
||||
}
|
||||
}
|
||||
|
||||
public void BoostToAnchor(InputAction.CallbackContext context){
|
||||
if(context.performed && grappled){
|
||||
if(context.performed && grappled && !boosted){
|
||||
boosted = true;
|
||||
soundPlayer.PlaySound("PlayerGrappleBoost");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Bytes.Sound;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
@ -9,7 +8,7 @@ public class PlayerController : MonoBehaviour
|
||||
private GrappleHook grappleScript;
|
||||
private CharacterMovement movementScript;
|
||||
private Rigidbody rb;
|
||||
SoundPlayer soundPlayer;
|
||||
[SerializeField] SoundPlayer soundPlayer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -32,6 +31,7 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
|
||||
public void Knockback(Vector2 dir){
|
||||
soundPlayer.PlaySound("PlayerKnockback");
|
||||
rb.AddForce(dir);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user