Initial commit

This commit is contained in:
Gregory Campbell
2019-09-29 19:40:54 -04:00
commit 463a783c7c
3583 changed files with 101769 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour
{
public bool useOffsetValues;
public bool invertY = false;
public float rotateSpeed = 1.0f;
public float maxViewAngle;
public float minViewAngle;
public Transform player;
public Transform pivot;
public Vector3 offset;
void Start () {
if(!useOffsetValues){
offset = player.position - transform.position;
}
pivot.position = player.position;
pivot.parent = player.transform;
Cursor.visible = !Cursor.visible;
Cursor.lockState = CursorLockMode.Locked;
}
void LateUpdate(){
float camX = Input.GetAxisRaw("Mouse X") * rotateSpeed;
player.Rotate(0, camX, 0);
float camY = Input.GetAxisRaw("Mouse Y") * rotateSpeed;
if (invertY){
pivot.Rotate(camY, 0, 0);
} else {
pivot.Rotate(-camY, 0, 0);
}
if(pivot.rotation.eulerAngles.x > maxViewAngle && pivot.rotation.eulerAngles.x < 180f)
{
pivot.rotation = Quaternion.Euler(maxViewAngle, 0, 0);
}
if(pivot.rotation.eulerAngles.x > 180f && pivot.rotation.eulerAngles.x < (360 + minViewAngle))
{
pivot.rotation = Quaternion.Euler(minViewAngle, 0, 0);
}
float camZ = Input.GetAxisRaw("Mouse ScrollWheel");
float angleX = pivot.eulerAngles.x;
float angleY = player.eulerAngles.y;
float cameraAngle = transform.eulerAngles.y;
//if (Mathf.Abs(cameraAngle - angleY) <= 45){ Potential start for camera following similar to banjo/mario64
Quaternion rotation = Quaternion.Euler(angleX, angleY, 0);
transform.position = player.position - (rotation * offset);
//}
if(transform.position.y < player.position.y){
transform.position = new Vector3(transform.position.x, player.position.y - 0.5f, transform.position.z);
}
transform.LookAt(player.position);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f648a3df441ef4243bc2d3b59166e6ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+66
View File
@@ -0,0 +1,66 @@
using UnityEngine;
using System.Collections;
// This script moves the character controller forward
// and sideways based on the arrow keys.
// It also jumps when pressing space.
// Make sure to attach a character controller to the same game object.
// It is recommended that you make only one call to Move or SimpleMove per frame.
public class PlayerController : MonoBehaviour
{
CharacterController characterController;
public float speed = 20.0f;
public float jumpSpeed = 15.0f;
public float gravity = 5.0f;
private bool extraJump = true;
private Vector3 moveDirection;
void Start()
{
characterController = GetComponent<CharacterController>();
}
void Update()
{
float yStore = moveDirection.y;
moveDirection = (transform.forward * Input.GetAxisRaw("Vertical")) + (transform.right * Input.GetAxisRaw("Horizontal"));
if (extraJump == true)
{
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
} else
{
moveDirection = (moveDirection.normalized * speed)/4; //Remove this line to make running diagonal the fastest standard run
}
moveDirection.y = yStore;
if (characterController.isGrounded)
{
extraJump = true;
moveDirection.y = 0.0f;
if (Input.GetButtonDown("Jump"))
{
moveDirection.y = jumpSpeed;
}
} else {
if (Input.GetButtonDown("Jump") && extraJump == true)
{
moveDirection.y = jumpSpeed;
extraJump = false;
}
}
moveDirection.y = moveDirection.y + (Physics.gravity.y * gravity * Time.deltaTime);
// Move the controller
characterController.Move(moveDirection * Time.deltaTime);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 83127dd120c01de45954b99cc4d669a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: