tvz wrote:it is possible to make it move perpendicular to the direction of mouse?
With angles this is pretty easy.
- Code: Select all
char* key = GetKeyState();
double ang = direction(xscreen, yscreen, xmouse, ymouse); // this gets the angle towards the mouse
// your rotation code would go here using ang
angle = ang + (key[KEY_RIGHT] - key[KEY_LEFT])*90; // plus or minus 90 of the direction to the mouse to make it perpendicular
directional_velocity = (key[KEY_RIGHT] || key[KEY_LEFT]) * 5; // 5 being the speed you want it to move
Note though that this will cause the player to rotate around the mouse if you put that in the draw actor event, as ang is constantly being updated. If you don't want that, then only update ang when you need to. You could also use the trig functions sin/cos to do this.