Files
Slendytubbies-V2-Beta/V2Beta/Assets/Scripts/Assembly-UnityScript/playerwalkingsound.cs
T
2026-05-24 12:14:04 +02:00

94 lines
2.1 KiB
C#

using System;
using UnityEngine;
[Serializable]
public class playerwalkingsound : MonoBehaviour
{
public AudioClip walkingsound;
public AnimationClip walkAnimation;
public virtual void Update()
{
Transform transform = GameObject.FindWithTag("Player").transform;
GetComponent<AudioSource>().clip = walkingsound;
GetComponent<AudioSource>().loop = true;
if (Input.GetKeyDown(KeyCode.W))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.W))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.S))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.S))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.A))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.A))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.D))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.D))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.UpArrow))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.DownArrow))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.LeftArrow))
{
GetComponent<AudioSource>().Stop();
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
GetComponent<AudioSource>().Play();
GetComponent<AudioSource>().loop = true;
}
if (Input.GetKeyUp(KeyCode.RightArrow))
{
GetComponent<AudioSource>().Stop();
}
}
public virtual void Main()
{
}
}