Merge branch 'master' of https://github.com/SweetTini/GlobalGameJam2020
This commit is contained in:
@@ -118,6 +118,7 @@ public class Player : MonoBehaviour
|
||||
// Jump
|
||||
if (Input.GetKeyDown(KeyCode.Space) && IsPlayerOnGround())
|
||||
{
|
||||
SoundManagerScript.PlaySound("jump");
|
||||
rigidBody.velocity += new Vector2(0, jumpSpeed);
|
||||
rigidBody.velocity = new Vector2(rigidBody.velocity.x,
|
||||
Mathf.Clamp(rigidBody.velocity.y, 0, jumpSpeed));
|
||||
|
||||
34
Assets/Scripts/SoundManagerScript.cs
Normal file
34
Assets/Scripts/SoundManagerScript.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SoundManagerScript : MonoBehaviour
|
||||
{
|
||||
|
||||
public static AudioClip jumpSound;
|
||||
static AudioSource audioSrc;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
jumpSound = Resources.Load<AudioClip>("Audio/Jump");
|
||||
|
||||
audioSrc = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void PlaySound(string clip)
|
||||
{
|
||||
switch (clip)
|
||||
{
|
||||
case "jump":
|
||||
audioSrc.PlayOneShot(jumpSound);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SoundManagerScript.cs.meta
Normal file
11
Assets/Scripts/SoundManagerScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc9d3b5f9d5d60b4596f3d065b900e30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user