kaasis Posted June 6, 2017 Share Posted June 6, 2017 Hi! I had this issue at very start when i started using Phaser but was always lazy to create topic about this. I searched everywhere and even tried different methods from google but none worked. The thing is that, it works actually, only if you don't use camera.follow(), without it works perfectly fine. But i when you use camera.follow() then it suddenly gives false values. So far i have used Phaser's Arcade's physics angleBetween() that works perfectly fine with camera.follow() and without it. But i don't want to use Physics as it slows down a bit performance and i don't even use any type of physics anyway 'cause my game is top down and i handle all my stuff without it anyway, so i don't see point using arcade physics just for angle rotation. If there are any solutions for this without using Physics, then comment down. Thanks in advance! Link to comment Share on other sites More sharing options...
samme Posted June 6, 2017 Share Posted June 6, 2017 Can you say exactly how you're using Math#angleBetween and Arcade#angleBetween? Link to comment Share on other sites More sharing options...
kaasis Posted June 6, 2017 Author Share Posted June 6, 2017 2 hours ago, samme said: Can you say exactly how you're using Math#angleBetween and Arcade#angleBetween? // using arcade's built in (works) this.player.rotation = this.physics.arcade.angleToPointer(this.player) // using math function (doesn't work) this.player.rotation = this.math.angleBetween(this.player.x,this.player.y,this.input.mousePointer.x,this.input.mousePointer.y) Link to comment Share on other sites More sharing options...
Antriel Posted June 7, 2017 Share Posted June 7, 2017 Given what you wrote, my guess is that you don't account for camera position. `player.x` is world position, `mousePointer.x` is relative to the screen. you probably want `mousePointer.worldX`. Link to comment Share on other sites More sharing options...
samid737 Posted June 7, 2017 Share Posted June 7, 2017 Hi, @Antriel is correct. If you inspect the source code of the angleToPointer function, you will find that it calculates using pointer.worldX. So if you want to use angleBetween, you have to pass worldX/Y... You don't really rely on arcade physics when using angleToPointer. Here is an example to demonstrate (the custom function is the exact same as arcade.physics.angleToPointer) : Link to comment Share on other sites More sharing options...
kaasis Posted June 7, 2017 Author Share Posted June 7, 2017 @Antriel yup worked. Didn't know it has 2 ways to get mouse position. Thanks! @samid737 and yeah, it actually doesn't really use arcade physics by itself if you use only angleToPointer by looking at that source code. Link to comment Share on other sites More sharing options...
samid737 Posted June 8, 2017 Share Posted June 8, 2017 16 hours ago, kaasis said: @Antriel yup worked. Didn't know it has 2 ways to get mouse position. Thanks! @samid737 and yeah, it actually doesn't really use arcade physics by itself if you use only angleToPointer by looking at that source code. Me neither! Glad to clearify it.. Link to comment Share on other sites More sharing options...
Recommended Posts