Rissk13 Posted July 9, 2018 Share Posted July 9, 2018 I'm trying to figure out the equivalent of this code (Arcade physics) for Matter physics. this.player.body.velocity.normalize().scale(this.player.speed); The goal being to make the player move diagonally at the same speed as only moving either horizontal/vertical. Right now it seems a little faster when setting the velocity X and Y to 3. Link to comment Share on other sites More sharing options...
SvenFrankson Posted July 9, 2018 Share Posted July 9, 2018 Maybe it will work with X = sqrt(3) and Y = sqrt(3) ? Link to comment Share on other sites More sharing options...
kurhlaa Posted July 9, 2018 Share Posted July 9, 2018 Shouldn't cosines be more precise? If your movement's angle is precisely 45 degrees: alpha = cos(45) x = 3 * alpha y = 3 * alpha SvenFrankson 1 Link to comment Share on other sites More sharing options...
SvenFrankson Posted July 9, 2018 Share Posted July 9, 2018 Oups, indeed kurhlaa is right here Link to comment Share on other sites More sharing options...
Recommended Posts