init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
46
Assets/Scripts/New/NewCheckPoint.cs
Normal file
46
Assets/Scripts/New/NewCheckPoint.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NewCheckPoint : MonoBehaviour{
|
||||
|
||||
[SerializeField, Range(0f, 10f)] float radius = 6f;
|
||||
|
||||
[SerializeField] GameObject lightToTurn;
|
||||
bool triggered;
|
||||
bool alreadyTriggered;
|
||||
|
||||
public int checkPointNumber { set; get; }
|
||||
|
||||
[SerializeField] MeshRenderer[] partsToTurnOn = default;
|
||||
[SerializeField] Material onMat = default;
|
||||
[SerializeField] Material offMat = default;
|
||||
|
||||
[SerializeField] LayerMask playerMask = default;
|
||||
PlayerMovement player;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
lightToTurn.SetActive(false);
|
||||
player = FindObjectOfType<PlayerMovement>();
|
||||
for (int i = 0; i < partsToTurnOn.Length; i++){
|
||||
partsToTurnOn[i].material = offMat;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
triggered = Physics.CheckSphere(transform.position, radius, playerMask);
|
||||
if(triggered && !alreadyTriggered){
|
||||
AudioManager.instance.Play("CheckPoint");
|
||||
gameObject.layer = 10;
|
||||
lightToTurn.SetActive(true);
|
||||
PlayerPrefs.SetInt("CheckPoint", checkPointNumber);
|
||||
alreadyTriggered = true;
|
||||
for (int i = 0; i < partsToTurnOn.Length; i++){
|
||||
partsToTurnOn[i].material = onMat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/New/NewCheckPoint.cs.meta
Normal file
11
Assets/Scripts/New/NewCheckPoint.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2714a0fc8430d234caac976f915bd9d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/New/PlayerMovement.cs
Normal file
44
Assets/Scripts/New/PlayerMovement.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour{
|
||||
|
||||
CharacterController controller;
|
||||
|
||||
[SerializeField, Range(0f, 1f)] float inputDeadZone = .125f;
|
||||
Vector2 playerInput;
|
||||
|
||||
[SerializeField] float speed = 5f;
|
||||
|
||||
Transform cam;
|
||||
float turnVelocity;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
cam = Camera.main.transform;
|
||||
controller = GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
public void PlayerMove(InputAction.CallbackContext state){
|
||||
Vector2 input = state.ReadValue<Vector2>();
|
||||
if(input.magnitude > inputDeadZone){
|
||||
playerInput = input;
|
||||
}else{
|
||||
playerInput = Vector2.zero;
|
||||
}
|
||||
playerInput = Vector2.ClampMagnitude(playerInput, 1);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if(playerInput.magnitude > inputDeadZone){
|
||||
float targetAngle = Mathf.Atan2(playerInput.normalized.x, playerInput.normalized.y) * Mathf.Rad2Deg + cam.eulerAngles.y;
|
||||
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnVelocity, .1f);
|
||||
transform.rotation = Quaternion.Euler(0f, angle, 0f);
|
||||
|
||||
controller.Move(new Vector3(playerInput.x, 0f, playerInput.y) * speed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/New/PlayerMovement.cs.meta
Normal file
11
Assets/Scripts/New/PlayerMovement.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 097cfa1879f24de4aa572b44e9e483cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue