Compare commits
No commits in common. "5a86b8b4f58e04975be2169d8e5c2910e6d2ff43" and "bd4fc70ca5dee9f3506037e77bd9556f108b202d" have entirely different histories.
5a86b8b4f5
...
bd4fc70ca5
|
@ -38,7 +38,7 @@ RenderSettings:
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 705507994}
|
m_Sun: {fileID: 705507994}
|
||||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
m_IndirectSpecularColor: {r: 0.17901866, g: 0.22415823, b: 0.30597454, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
|
@ -2721,20 +2721,9 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 552825307}
|
m_GameObject: {fileID: 552825307}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 740b300bbbdc1fa4f9acfc855c8670de, type: 3}
|
m_Script: {fileID: 11500000, guid: 41df0369bf5d3b64cb9c32c46f2fe9f0, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
moveSpeed: 3
|
|
||||||
groundDrag: 1
|
|
||||||
speed: 5
|
|
||||||
jumpKey: 32
|
|
||||||
jumpForce: 4
|
|
||||||
jumpCooldown: 0.5
|
|
||||||
playerHeight: 1
|
|
||||||
whatIsGround:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 8
|
|
||||||
grounded: 0
|
|
||||||
--- !u!136 &552825310
|
--- !u!136 &552825310
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -9724,18 +9713,11 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 707d39e7a8ed7a44a8341ead8ee2a9ad, type: 3}
|
m_Script: {fileID: 11500000, guid: 707d39e7a8ed7a44a8341ead8ee2a9ad, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
<<<<<<< HEAD
|
|
||||||
_caffeine_level: 0
|
|
||||||
_hunger_level: 0
|
|
||||||
_happiness_level: 100
|
|
||||||
_developement_power: 100
|
|
||||||
=======
|
|
||||||
_caffeineLevel: 0
|
_caffeineLevel: 0
|
||||||
_hungerLevel: 0
|
_hungerLevel: 0
|
||||||
_happinessLevel: 100
|
_happinessLevel: 100
|
||||||
_developementPower: 100
|
_developementPower: 100
|
||||||
eventRate: 1
|
eventRate: 1
|
||||||
>>>>>>> bd4fc70ca5dee9f3506037e77bd9556f108b202d
|
|
||||||
--- !u!1001 &1901183706
|
--- !u!1001 &1901183706
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
|
|
||||||
public class Character : MonoBehaviour
|
|
||||||
{
|
|
||||||
[Header("Movement")]
|
|
||||||
public float moveSpeed = 2f;
|
|
||||||
public float groundDrag = 1f;
|
|
||||||
|
|
||||||
private float horizontalInput, verticalInput;
|
|
||||||
private Vector3 moveDirection;
|
|
||||||
private Rigidbody rb;
|
|
||||||
|
|
||||||
public float speed = 2f;
|
|
||||||
|
|
||||||
[Header("Keybindings")]
|
|
||||||
public KeyCode jumpKey = KeyCode.Space;
|
|
||||||
|
|
||||||
public float jumpForce;
|
|
||||||
public float jumpCooldown;
|
|
||||||
bool readyToJump = true;
|
|
||||||
|
|
||||||
[Header("Groud Check")]
|
|
||||||
public float playerHeight;
|
|
||||||
public LayerMask whatIsGround;
|
|
||||||
public bool grounded;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
rb = gameObject.GetComponent<Rigidbody>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);
|
|
||||||
|
|
||||||
MyInput();
|
|
||||||
SpeedControl();
|
|
||||||
|
|
||||||
if (grounded)
|
|
||||||
{
|
|
||||||
rb.drag = groundDrag;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rb.drag = 0.3f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
MovePlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MyInput()
|
|
||||||
{
|
|
||||||
horizontalInput = Input.GetAxisRaw("Horizontal");
|
|
||||||
verticalInput = Input.GetAxisRaw("Vertical");
|
|
||||||
|
|
||||||
|
|
||||||
if (Input.GetKey(jumpKey) && readyToJump && grounded)
|
|
||||||
{
|
|
||||||
readyToJump = false;
|
|
||||||
|
|
||||||
Jump();
|
|
||||||
|
|
||||||
Invoke(nameof(ResetJump), jumpCooldown);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MovePlayer()
|
|
||||||
{
|
|
||||||
moveDirection = new Vector3(0, 0, verticalInput) + new Vector3(horizontalInput, 0, 0);
|
|
||||||
|
|
||||||
rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SpeedControl()
|
|
||||||
{
|
|
||||||
Vector3 flatVel = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
|
|
||||||
|
|
||||||
if (flatVel.magnitude > moveSpeed)
|
|
||||||
{
|
|
||||||
Vector3 limitedVel = flatVel.normalized * moveSpeed;
|
|
||||||
rb.velocity = new Vector3(limitedVel.x, rb.velocity.y, limitedVel.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Jump()
|
|
||||||
{
|
|
||||||
rb.velocity = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
|
|
||||||
|
|
||||||
rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ResetJump()
|
|
||||||
{
|
|
||||||
readyToJump = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 740b300bbbdc1fa4f9acfc855c8670de
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
Loading…
Reference in New Issue