public float walkingSpeed = 7.5f;
public float runningSpeed = 11.5f;
public float gravity = 20.0f;
public float lookSpeed = 2.0f;
public float lookXLimit = 45.0f;
public float scet;
public AudioSource myFx;
public AudioClip FlashlightClipFx;
public AudioClip letterFx;
public AudioClip examFx;
public AudioClip keyFx;
public AudioClip UpFx;
public AudioClip doorFx;
public AudioClip monsterAroundFx;
public AudioClip closeDoorFx;
public AudioClip footstepSound;
public Text txt;
public Text countTxt;
public int Energy;
public int count_answers = 0;
private RaycastHit hit;
public Camera playerCamera;
public GameObject Light;
public GameObject _letter1;
public GameObject _letter2;
public GameObject _letter3;
public GameObject _letter4;
public GameObject textExit;
public GameObject fade_panel;
public GameObject trigerEnd;
public GameObject collectionLetter;
public GameObject buttonLetter;
public GameObject Button_Up;
private bool exit_door;
private bool _letter1_bool;
private bool _letter2_bool;
private bool _letter3_bool;
private bool _letter4_bool;
public bool doorIsOpen = false;
public bool onLight;
public Animator camAnimator;
public AudioSource walkAudioSource;
[HideInInspector]
public Vector2 RunAxis;
[HideInInspector]
public Vector2 LookAxis;
CharacterController characterController;
Vector3 moveDirection = Vector3.zero;
float rotationX = 0;
[HideInInspector]
public bool canMove = true;
void Start()
{
walkAudioSource = GetComponent<AudioSource>();
camAnimator = GameObject.FindGameObjectWithTag("camera").GetComponent<Animator> ();
characterController = GetComponent<CharacterController>();
_letter1_bool = false;
_letter2_bool = false;
_letter3_bool = false;
_letter4_bool = false;
}
void Update()
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * RunAxis.y : 0;
float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * RunAxis.x : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
moveDirection.y = movementDirectionY;
if (!characterController.isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
characterController.Move(moveDirection * Time.deltaTime);
if (canMove)
{
rotationX += -LookAxis.y * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, LookAxis.x * lookSpeed, 0);
}
txt.text = Energy + "%";
if (onLight == true)
{
scet += 1 * Time.deltaTime;
if (scet >= 2)
{
Energy -= 1;
scet = 0;
}
}
if (Energy >= 100)
{
Energy = 100;
}
if (Energy <= 0)
{
onLight = false;
Light.SetActive (false);
Energy = 0;
}
}
}
.... далее функции, слишком большой код, телеграм не пропускает
выложи на pastberin
https://pastebin.com/FmzAgLdM
Обсуждают сегодня