mb fixed CharacterController; FpsCount

This commit is contained in:
DerTyp187
2021-10-13 08:50:54 +02:00
parent 475110316b
commit 5e15b47d35
4 changed files with 28 additions and 23 deletions

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -352,9 +352,9 @@ MonoBehaviour:
walkSpeed: 6
moveSmoothTime: 0.05
gravity: -13
jumpHeight: 2.5
jumpHeight: 2
groundCheck: {fileID: 1473696487}
groundDistance: 1
groundDistance: 0.2
groundMask:
serializedVersion: 2
m_Bits: 64
@@ -373,7 +373,7 @@ CharacterController:
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_StepOffset: 0.05
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 1, z: 0}
@@ -743,11 +743,11 @@ RectTransform:
m_Father: {fileID: 145653193}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 230.1, y: 265.52}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -14, y: -25}
m_SizeDelta: {x: 560.5, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
m_Pivot: {x: 1, y: 1}
--- !u!114 &857589338
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1151,11 +1151,11 @@ RectTransform:
m_Father: {fileID: 145653193}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 230.1, y: 299.26}
m_SizeDelta: {x: 560.5, y: 17.47}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -14, y: 0.000030517578}
m_SizeDelta: {x: 560.5, y: 17.470001}
m_Pivot: {x: 1, y: 1}
--- !u!114 &1960893055
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1265,8 +1265,8 @@ GameObject:
- component: {fileID: 2119583732}
- component: {fileID: 2119583731}
- component: {fileID: 2119583730}
m_Layer: 0
m_Name: s
m_Layer: 6
m_Name: TestUnityCube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@@ -7,9 +7,15 @@ public class DebugCanvas : MonoBehaviour
{
public TextMeshProUGUI DebugTextGrounded;
public GameObject Player;
public TextMeshProUGUI fpsText;
public float deltaTime;
private void Update()
{
DebugTextGrounded.text = "isGrounded: " + Player.GetComponent<PlayerController>().isGrounded.ToString();
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
float fps = 1.0f / deltaTime;
fpsText.text = Mathf.Ceil(fps).ToString() + "FPS";
}
}

View File

@@ -72,6 +72,10 @@ public class PlayerController : MonoBehaviour
}
private void UpdateMovement()
{
//Grounded
velocityY += gravity * Time.deltaTime;
if (isGrounded && velocityY < 0)
velocityY = 0.0f;
//Jump
if (Input.GetButtonDown("Jump") && isGrounded)
@@ -80,14 +84,6 @@ public class PlayerController : MonoBehaviour
velocityY += Mathf.Sqrt(jumpHeight * -2f * gravity);
}
//Grounded
if (isGrounded)
velocityY = 0.0f;
velocityY += gravity * Time.deltaTime;
Vector2 targetDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); //Get Inputs
targetDir.Normalize(); //Damit schr<68>g laufen nicht schneller ist