#Wrong movement at low fps (definitely because of the deltaTime)
1 messages · Page 1 of 1 (latest)
So, are you going to answer the 2nd question? Are you using Time.deltaTime?
Wrong movement at low fps (definitely because of the deltaTime)
yeah sorry, time.delta time is being used. i think at a low fps, sometimes the ball goes through the floor?
Nice
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
Why isn't the override Update method calling its base?
because base is empty
Alright, makes sense
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
Well, the cc.Move(moveVector * Time.delta) is where the ball is supposed to move, right?
The deltaTime is applied, so...
YEAH
caps
i think it might be something rigidbody handles internally
And it's definitely not applied anywhere else?
time.deltatime?
Yes
gets applied on gravity and drag calculatio
they are applied to the move vector before cc.Move is called
That's not what I'm talking about.
Is moveVector being directly affected by the Time.deltaTime
Apart from multiplying it with the Time.deltaTime when moving the cc
it shouldnt be no
the code you see is the only place it gets affected by delta
What about these 2 methods?
moveVector = FightPhysics.ApplyGravity(moveVector);
moveVector = FightPhysics.CalcEnv(moveVector, 0.5f);
I need to see them
i sent them already ?
im confused
Oh, yeah, haven't mentioned
The value mutliplied by the Time.deltaTime is added in both methods.
Remove the Time.deltaTime from both calculations and your issue should be fixed
now everything just falls so fast ðŸ˜
Well, of course
lemme change some things
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
out of curiosity why would removing dt fix the issue?
Well, you say, the angle of the ball's direction is smaller with smaller fps, isn't it?
yeah, but i dont see how changing the gravity would fix this issue. right now, that only changes drag and stuff
i think its because cc.Move doesnt handle collisions well at a low fps
Alright. So the angle may be 20 with a small fps and 50 with a greater one?
i think i understand what youre trying to say, but the actual angle calculated is not dependent on delta time
So, could you answer the question first?
the angle is different, but i think thats because of the collision being handled badly at a low frame rate
The ball's angle is calculated here, isn't it?
transform.LookAt(moveVector.normalized);
no, thats just for the stretchy effect you see
angle is calculated by the big physics class i showed u earlier
And the fps affects just the angle?
basically, but again i think its because the ball falls underneath the floor
Well, I thought that's where the angle is calculated, so told you to change the deltaTime applied
How is this related?
because it falls under the floor, it calculates the wrong point of collision and makes an erroneous calculation
Alright, could you send the code, which calculates the angle?
angles arent directly calculated, im just using augmenting the vector 2
Alright, yeah, I mean the direction
The fightphysics thing calculates all that jazz
moveVector = FightPhysics.ApplyGravity(moveVector);
moveVector = FightPhysics.CalcEnv(moveVector, 0.5f);
cc.Move(moveVector * Time.deltaTime);
thats all being dealt with it
Yeah, so you set the velocity to the velocity multipled by deltaTime.
velocity -= velocity * Time.deltaTime
Removing the Time.deltaTime should fix the issue
okay thank you :)
Try it out.
will do
In this case it's not like decreasing the velocity by Time.deltaTime multiplied by a constant value
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?
yeah that makes sense