init
This commit is contained in:
commit
102013b228
1443 changed files with 1065651 additions and 0 deletions
89
Assets/Scripts/Menu/MenuPlayerMovement.cs
Normal file
89
Assets/Scripts/Menu/MenuPlayerMovement.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MenuPlayerMovement : MonoBehaviour{
|
||||
|
||||
[SerializeField] Transform cam;
|
||||
[SerializeField] float speed = 7.5f;
|
||||
CharacterController controller;
|
||||
[SerializeField] public Animator anim;
|
||||
|
||||
[SerializeField] float gravityScale = 9.8f;
|
||||
[SerializeField] LayerMask whatIsGround = -1;
|
||||
[SerializeField] float feetRadius;
|
||||
[SerializeField] Transform feetPos;
|
||||
bool isGrounded;
|
||||
Vector3 velocity;
|
||||
|
||||
float yVelocity;
|
||||
float yVelocityVelocity;
|
||||
|
||||
[SerializeField, Range(0, .3f)] float turnSmoothTime = .1f;
|
||||
float turnSmoothVelocity;
|
||||
|
||||
|
||||
[SerializeField, Min(0)] float gravity = 15f;
|
||||
|
||||
float currentX;
|
||||
float xDirVelocity;
|
||||
float currentY;
|
||||
float yDirVelocity;
|
||||
float velocityChangeVelocity;
|
||||
|
||||
[SerializeField, Range(0, 1f)] float stepsInterval = .5f;
|
||||
float currentTime;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
controller = GetComponent<CharacterController>();
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (anim != null && Time.timeScale == 1)
|
||||
{
|
||||
|
||||
float horizontal = Input.GetAxisRaw("Horizontal");
|
||||
float vertical = Input.GetAxisRaw("Vertical");
|
||||
Vector3 direction = new Vector3(horizontal, 0, vertical).normalized;
|
||||
|
||||
if (direction.magnitude >= .1f)
|
||||
{
|
||||
currentTime += Time.deltaTime;
|
||||
if(currentTime >= stepsInterval){
|
||||
AudioManager.instance.PlayOneShot("SFX_paso" + Random.Range(1, 6), true);
|
||||
currentTime = 0;
|
||||
}
|
||||
|
||||
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
|
||||
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
|
||||
transform.rotation = Quaternion.Euler(0, angle, 0);
|
||||
|
||||
Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
|
||||
controller.Move(moveDir.normalized * speed * Time.deltaTime);
|
||||
|
||||
Vector3 directionX = direction.x * transform.forward;
|
||||
Vector3 directionZ = direction.z * transform.forward;
|
||||
currentX = Mathf.SmoothDamp(currentX, directionX.x, ref xDirVelocity, .1f);
|
||||
currentY = Mathf.SmoothDamp(currentY, directionZ.z, ref xDirVelocity, .1f);
|
||||
anim.SetFloat("Dance", 0);
|
||||
yDirVelocity = 1;
|
||||
}else{
|
||||
currentX = Mathf.SmoothDamp(currentX, 0, ref xDirVelocity, .1f);
|
||||
currentY = Mathf.SmoothDamp(currentY, 0, ref xDirVelocity, .1f);
|
||||
yDirVelocity = 0;
|
||||
}
|
||||
|
||||
float vel = Mathf.SmoothDamp(anim.GetFloat("VelocityY"), yDirVelocity, ref velocityChangeVelocity, .1f);
|
||||
anim.SetFloat("VelocityY", vel);
|
||||
|
||||
velocity.y -= gravity * Time.deltaTime;
|
||||
controller.Move(velocity * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Menu/MenuPlayerMovement.cs.meta
Normal file
11
Assets/Scripts/Menu/MenuPlayerMovement.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcc3d572367c55141bb86a759b2d2a77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Scripts/Menu/PlaySounds.cs
Normal file
26
Assets/Scripts/Menu/PlaySounds.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlaySounds : MonoBehaviour{
|
||||
|
||||
[SerializeField] bool playIntro = true;
|
||||
|
||||
void Start(){
|
||||
if (playIntro){
|
||||
AudioManager.instance.Play("Intro");
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayMusic(string name){
|
||||
AudioManager.instance.Play(name);
|
||||
}
|
||||
|
||||
public void StopMusic(string name){
|
||||
AudioManager.instance.Play(name);
|
||||
}
|
||||
|
||||
public void PlayOneShot(string name){
|
||||
AudioManager.instance.PlayOneShot(name);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Menu/PlaySounds.cs.meta
Normal file
11
Assets/Scripts/Menu/PlaySounds.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8aafc487c65f41488d855dbfa6e5ed7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue