mirror of
				https://github.com/GayPizzaSpecifications/voxelotl-engine.git
				synced 2025-11-04 02:59:37 +00:00 
			
		
		
		
	ignore acceleration & friction for smoother movement for the time being
This commit is contained in:
		@ -10,8 +10,7 @@ struct Player {
 | 
				
			|||||||
  static let eyeLevel: Float = 1.4
 | 
					  static let eyeLevel: Float = 1.4
 | 
				
			||||||
  static let epsilon = Float.ulpOfOne * 10
 | 
					  static let epsilon = Float.ulpOfOne * 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static let speedCoeff: Float = 75
 | 
					  static let accelerationCoeff: Float = 7.5
 | 
				
			||||||
  static let frictionCoeff: Float = 12.5
 | 
					 | 
				
			||||||
  static let gravityCoeff: Float = 12
 | 
					  static let gravityCoeff: Float = 12
 | 
				
			||||||
  static let jumpVelocity: Float = 9
 | 
					  static let jumpVelocity: Float = 9
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -41,8 +40,8 @@ struct Player {
 | 
				
			|||||||
        // Movement on ground
 | 
					        // Movement on ground
 | 
				
			||||||
        let movement = pad.leftStick.cardinalDeadzone(min: 0.1, max: 1)
 | 
					        let movement = pad.leftStick.cardinalDeadzone(min: 0.1, max: 1)
 | 
				
			||||||
        let rotc = cos(self._rotation.x), rots = sin(self._rotation.x)
 | 
					        let rotc = cos(self._rotation.x), rots = sin(self._rotation.x)
 | 
				
			||||||
        self._velocity.x += (movement.x * rotc - movement.y * rots) * Self.speedCoeff * deltaTime
 | 
					        self._velocity.x = (movement.x * rotc - movement.y * rots) * Self.accelerationCoeff
 | 
				
			||||||
        self._velocity.z += (movement.y * rotc + movement.x * rots) * Self.speedCoeff * deltaTime
 | 
					        self._velocity.z = (movement.y * rotc + movement.x * rots) * Self.accelerationCoeff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Jumping
 | 
					        // Jumping
 | 
				
			||||||
        if pad.pressed(.east) {
 | 
					        if pad.pressed(.east) {
 | 
				
			||||||
@ -110,8 +109,8 @@ struct Player {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Ground friction
 | 
					    // Ground friction
 | 
				
			||||||
    if self._onGround {
 | 
					    if self._onGround {
 | 
				
			||||||
      self._velocity.x -= self._velocity.x * Self.frictionCoeff * deltaTime
 | 
					      self._velocity.x = 0
 | 
				
			||||||
      self._velocity.z -= self._velocity.z * Self.frictionCoeff * deltaTime
 | 
					      self._velocity.z = 0
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user