Added Framecap

This commit is contained in:
DominikB
2023-06-25 11:47:17 +02:00
parent 12735a14ee
commit a3cfd71e42
7 changed files with 55 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 2410396854066836746}
- component: {fileID: 2410396854066836741}
- component: {fileID: 2410396854066836740}
- component: {fileID: 7151566526002050665}
- component: {fileID: 2410396854066836743}
- component: {fileID: 2410396854066836742}
- component: {fileID: 2410396854066836737}
@@ -114,6 +115,19 @@ MonoBehaviour:
gravityScale: 1.5
mainCamera: {fileID: 0}
grounded: 0
--- !u!114 &7151566526002050665
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7ac3ef522080e44c08e9a869c54f1e8e, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 60
--- !u!70 &2410396854066836743
CapsuleCollider2D:
m_ObjectHideFlags: 0
@@ -263,6 +277,7 @@ MonoBehaviour:
landeSound: {fileID: 8300000, guid: 183f7f089c24b164281e8c5053739412, type: 3}
sprungSound: {fileID: 8300000, guid: 3102ff7609304d84d824678029971c73, type: 3}
isJumping: 0
counterFall: 0
--- !u!82 &1535821441
AudioSource:
m_ObjectHideFlags: 0

View File

@@ -0,0 +1,18 @@
using UnityEngine;
public class FPSTarget : MonoBehaviour
{
public int target = 30;
void Awake()
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = target;
}
void Update()
{
if(Application.targetFrameRate != target){
Application.targetFrameRate = target;}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ac3ef522080e44c08e9a869c54f1e8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -12,7 +12,7 @@ public class FallingDetection : MonoBehaviour
public AudioClip landeSound; // The sound clip to be played
public AudioClip sprungSound; // The sound clip to be played
public bool isJumping = false;
private int counterFall = 0;
public int counterFall = 0;
private void Start()
@@ -37,11 +37,11 @@ public class FallingDetection : MonoBehaviour
//Wenn nicht auf boden und geschwindigkeits offset neg
if (!charController.grounded && velocity.y < -0.1f) {
//Wenn er bereits fällt, oder der counter erreicht ist zum fallen
if (isFalling || counter++>90) {
if (isFalling || counter++>20) {
isFalling = true;
animator.SetBool("IsFalling", true);
counter = 0;
if(counterFall++>180){
if(counterFall++>35){
wasFallingbefore = true;}
}
} else {