- Home /
Too much FPS, is there a cutoff limit?
Hey guys, I know this is a noobish question. But how come when I hit the 100 FPS (Frames Per Second) mark my game acts as if its as slow as 30 Frames a Second.
I'm assuming it works the same way as a movie, the more frames a second the more of a Slow Motion fluid like motion, which I understand.
But I've seen people player games with WAY more Frames Per Second and it just play as if it were at 60.
Is there a way to cap off the Frames Per Second? Such as still show the 100 FPS but work as if it was at 60. Because it confuses me sometimes thinking I have to much stuff on levels, etc.
Thanks guys.
What kind of code are we talking about here ? Do you use Time.deltaTime or the current framerate for some calculations in unusual ways?
Answer by Unitraxx · Oct 02, 2014 at 05:22 PM
If this solely happens with the game you developed then you likely misused the update functions. Look into Time.deltatime
and FixedUpdate
to make actions/movements framerate independent.
Thanks for all the help guys, I'll look more into the problems...
Pacbyte - I have a Sony Vaio Icore 3 2.4 Ghz Proces with 4 gigs of ram, and apparently close to 2 gig graphics card (1699 megs) of Ram on it.
Levo - here is my walking forward code, I would use AddForce, but I haven't figured out how to make it stop faster it just slides unrealistically lol... But here is my walking forward code (WITH, my animation)
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.W)) {
transform.Translate (Vector3.forward * speed * Time.deltaTime);
anim.SetFloat ("Speed", 1f);
} else {
anim.SetFloat ("Speed", 0f);
}
I do have it in a FixedUpdate, can that cause the problems? Because I'm using a Rigidbody to work with Physics, but I was just trying to do movement with transform.Translate and everything works fine! Just that slow jerk when I get a bit to many frames.
I'm gonna try to recreate my movement script as well and use nothing but Rigidbody stuff and see if that helps!
Answer by RedDevil · Oct 02, 2014 at 09:25 AM
The amount of frames someone can feel depends on the monitors refresh rate. The refresh rate on 90% of the screens is 59-60 so even if you have 1.0000.0000 FPS you will still feel like it is running on 60 FPS.Now there are monitors that can go to 120 FPS(gaming monitors) and there you can feel the extra FPS.
Yeah I know, but thats where this is getting confusing. When it runs at 60 fps it seems fine. I disable Vsync it goes to like 900, all fine and dandy, it runs fine as if I were running at 60 FPS. But when Vsync enabled, when I hit 90-100 range and beyond when i get it, it seems as if its running in slow motion. Like something that would take me 3 seconds to do will take 6 seconds. But that's only when I am getting a good high FPS. when it ranges from 0 to 89 it runs fine.
if you put VSync to enabled it should not go beyond 60. VSync or Vertical Sync syncs the game with the refresh rate so maybe you have more then 60.
There is no need to lock the frame rate on PC games. If there is something I hate its V-sync.
If your movement goes faster because of more frame rates then you're not using Time.deltatime
I was gonna say the same @levoTNTO , but he says it rons slower when FPS is higher
Answer by N1warhead · Oct 04, 2014 at 01:17 PM
using UnityEngine;
using System.Collections;
// REQUIRED COMPONENTS TO WORK!
[RequireComponent(typeof (Animator))]
public class Controller : MonoBehaviour {
//private CapsuleCollider col; // This is the Collider for Player.
private Animator anim; // This is the Animator for Player.
public float Speed = 5.0f;
public float TurnSpeed = 5.0f;
public float jumpHeight = 10.0f;
public bool canJump;
// Use this for initialization
void Start () {
anim = gameObject.GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
transform.Translate (Vector3.forward * Speed * Time.deltaTime);
anim.SetFloat ("Speed", 1f);
} else {
anim.SetFloat ("Speed", 0f);
}
if (Input.GetKey (KeyCode.S)){
transform.Translate (Vector3.back * Speed * Time.deltaTime);
anim.SetFloat ("WalkBack", -1f);
} else {
anim.SetFloat ("WalkBack", 0f);
}
if(Input.GetKey (KeyCode.A)){
transform.Rotate (0,-5,0);
}
if(Input.GetKey (KeyCode.D)){
transform.Rotate (0,5,0);
}
}
void FixedUpdate(){
if (Input.GetKeyDown (KeyCode.Space) && canJump == true) {
if (canJump) {
anim.SetBool ("Jump", true);
transform.rigidbody.AddForce (Vector3.up * jumpHeight);
Physics.gravity = new Vector3 (0, -20, 0);
}
}
}
void OnCollisionEnter(Collision col){
if (col.gameObject.tag == "Map") {
anim.SetBool ("Jump", false);
}
}
}
And here is my trigger script -
using UnityEngine;
using System.Collections;
public class ObjectDetection : MonoBehaviour {
// This accesses the Players Controller.
public Controller controller;
// This script detects if the player is within a certain height from the tag
// of "Map" if map is triggered then allow the jumping to true
// otherwise can not jump (PREVENTS INFINITE JUMPING)
void OnTriggerEnter(Collider col){
if (col.gameObject.tag == "Map") {
Debug.Log ("Object Detected");
controller.canJump = true;
}
}
void OnTriggerExit(Collider col){
if (col.gameObject.tag == "Map") {
Debug.Log ("Object no longer detected");
controller.canJump = false;
}
}
}
For some reason it didn't show my text I put.
Pretty much my FPS is sky rocketing to 110-120 FPS at 8 $$anonymous$$iliseconds.
and my trigger for my JU$$anonymous$$P BOOL in Controller is acting up.
Okay I'm an Idiot, I just took the jump out the FixedUpdate and it works like a charm now lol... I always read that AddForces and stuff needed to be in a Fixed Update.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
DateTime rocket launcher timing issue 2 Answers
FPS KIT VERSION 2.0 0 Answers
Hi all. I am new to unity. And the problem is with the FPS of my scene. 1 Answer
Players unexpectedly change positions 0 Answers