Trying to apply force to a object proportionally to the x and y based on where the mouse was clicked

GML:
function scr_pushPlayer(playerID, mouse_x_value, mouse_y_value){

    var total = mouse_x_value + mouse_y_value
//these should be velocitys but im using speed because I havent yet set up velocity
    playerID.x_velocity = scr_roundTo((mouse_x_value/total)%15 * playerID.forceTotalVelocity * sign(playerID.x - mouse_x_value), .01)
    playerID.y_velocity = scr_roundTo((mouse_y_value/total)%15 * playerID.forceTotalVelocity * sign(playerID.y - mouse_y_value), .01)
    show_debug_message(playerID.x_velocity)
    show_debug_message(playerID.y_velocity)
}
So basically x_velocity and y_velocity are being used to store the velocity of the object. But I'm having problems because I want the value to be proportional to where the mouse is clicked but essentially as if it was clicked around a circle, with no regard given to how far away in the direction the mouse was clicked.
 

Ommn

Member
try this:
GML:
function scr_pushPlayer(playerID, mouse_x_value, mouse_y_value){
    //these should be velocitys but im using speed because I havent yet set up velocity
    playerID.x_velocity = scr_roundTo((playerID.forceTotalVelocity * clamp(playerID.x - mouse_x_value,-15,15), .01)
    playerID.y_velocity = scr_roundTo((playerID.forceTotalVelocity * clamp(playerID.y - mouse_y_value,-15,15), .01)
    show_debug_message(playerID.x_velocity)
    show_debug_message(playerID.y_velocity)
}
 
Top