#Wrong movement at low fps (definitely because of the deltaTime)

1 messages · Page 1 of 1 (latest)

wispy matrix
#

So, are you going to answer the 2nd question? Are you using Time.deltaTime?

#

Wrong movement at low fps (definitely because of the deltaTime)

hollow forum
wispy matrix
#

Could you send the code you're using?

hollow forum
# wispy matrix Could you send the code you're using?
protected override void Update()
    {
        baseballStretch = moveVector.magnitude;
        baseballStretch = Mathf.Clamp(baseballStretch, baseballShape.transform.localScale.x, 24f);
        transform.LookAt(moveVector.normalized);
        moveVector = FightPhysics.ApplyGravity(moveVector);
        moveVector = FightPhysics.CalcEnv(moveVector, 0.5f);
        cc.Move(moveVector * Time.deltaTime);
        damage = moveVector.magnitude / 300;
        projectileHitStunLength = 0.3f;
        projectileLaunchForce = 10f * (moveVector.magnitude / 34.5f);
        projectileStunLength = 0.6f;
        baseballShape.transform.localScale =
            new Vector3(baseballShape.transform.localScale.x, baseballShape.transform.localScale.y,baseballStretch);
        float angle = Mathf.Atan2(moveVector.y, moveVector.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        destroyTimer -= Time.deltaTime;
        if (destroyTimer <= 0)
        {
            DestroyProjectile();
        }
        
    }
#

code that the baseball runs

#

cc is the characterController

wispy matrix
#

Why isn't the override Update method calling its base?

hollow forum
wispy matrix
#

Alright, makes sense

hollow forum
#

thats like just in case

#

if i need to add a global projectile behaviour

#

it appears sometimes the projectile bouncing is actually broken on high fps too

wispy matrix
#

The deltaTime is applied, so...

hollow forum
#

caps

#

i think it might be something rigidbody handles internally

wispy matrix
#

And it's definitely not applied anywhere else?

hollow forum
wispy matrix
#

Yes

hollow forum
wispy matrix
#

Where are they used?

#

Are they perhaps applied to the moveVector?

hollow forum
#

they are applied to the move vector before cc.Move is called

wispy matrix
#

Is moveVector being directly affected by the Time.deltaTime

#

Apart from multiplying it with the Time.deltaTime when moving the cc

hollow forum
#

the code you see is the only place it gets affected by delta

wispy matrix
#

I need to see them

hollow forum
#

im confused

wispy matrix
wispy matrix
#

Remove the Time.deltaTime from both calculations and your issue should be fixed

hollow forum
wispy matrix
hollow forum
#

lemme change some things

wispy matrix
#

Time.timeTime is 1 divided by your fps

#

If it's, say, 50, the force applied will be multiplied by 1 / 50 = 0.02 and will be thus 50 times smaller

hollow forum
wispy matrix
#

Well, you say, the angle of the ball's direction is smaller with smaller fps, isn't it?

hollow forum
#

i think its because cc.Move doesnt handle collisions well at a low fps

wispy matrix
hollow forum
wispy matrix
hollow forum
wispy matrix
hollow forum
#

angle is calculated by the big physics class i showed u earlier

wispy matrix
#

And the fps affects just the angle?

hollow forum
wispy matrix
hollow forum
wispy matrix
hollow forum
wispy matrix
#

Alright, yeah, I mean the direction

hollow forum
#

thats all being dealt with it

wispy matrix
#

Removing the Time.deltaTime should fix the issue

hollow forum
#

okay thank you :)

wispy matrix
#

Try it out.

hollow forum
#

will do

wispy matrix
#
2 frames per second - 0.5
100 - 100 * 0.5           =>  50
50 - 50 * 0.5             =>  25         - end result after a frame

4 frames per second - 0.25
100 - 100 * 0.25          =>  75
75 - 75 * 0.25            =>  56.25
56.25 - 56.25 * 0.25      =>  42.1875
42.1875 - 42.1875 * 0.25  =>  31.640625  - end result after a frame
#

See the difference, right?

hollow forum
#

yeah that makes sense