'How do I rotate my player object so it faces my mouse in Cocos Creator
I want to make it so my player object faces my mouse so he can shoot stuff. So far with the code I have it just rotates wonky and wrong. What am I doing wrong?
onMouseMove(m:EventMouse){
var facing = new Vec2(
m.getLocation().x - this.node.getPosition().x,
m.getLocation().y - this.node.getPosition().y);
var angle = Math.atan2(facing.y, facing.x) * 180 / Math.PI;
this.node.setRotationFromEuler(new Vec3(0, 0, angle));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
