void FixedUpdate () {
ApplyFrictionExp();
if(Controller != null && Controller.isKinematic == false) {
Controller.velocity = Velocity * Time.deltaTime;
}
if(Velocity.x == 0 && Velocity.y == 0)
{
Controller.isKinematic = true;
}
else
{
Controller.isKinematic = false;
}
}
This is the code im using, might not be the best but…
My problem is for one, the velocity is massively slow since adding this, another problem is even after upping the amount that im adding the the Velocity varaible it still seems innacurate when switching graphic settings?
protected void ApplyJumpLogic() {
if(CurrentJumps > 0)
{
if(Input.GetKeyDown(KeyCode.Space))
{
CurrentJumps--;
Velocity.y = Jump;
}
}
}
Jump Code ^
protected void ApplyMovementLogic() {
if(Input.GetKey(KeyCode.RightArrow))
{
Velocity.x += Speed;
AttackDirection = Direction.Right;
HorizontalAttackDirection = HorizontalDirection.Right;
}
else if(Input.GetKey(KeyCode.LeftArrow))
{
Velocity.x -= Speed;
AttackDirection = Direction.Left;
HorizontalAttackDirection = HorizontalDirection.Left;
}
else if(Input.GetKey(KeyCode.UpArrow))
{
AttackDirection = Direction.Up;
}
else if(Input.GetKey(KeyCode.DownArrow))
{
AttackDirection = Direction.Down;
}
}
Movement Code ^
protected void ApplyGravity() {
Velocity.y -= Gravity;
}
Gravity Code ^
protected void ApplyFrictionExp() {
if(Velocity.x >= 0.1 || Velocity.x <= -0.1)
{
Velocity.x *= FrictionExp;
}
else
{
Velocity.x = 0;
}
Velocity.y = Mathf.Clamp(Velocity.y, -MaxFallSpeed, Velocity.y);
}
Friction Code ^