Legacy GM Ragdoll Towards Mouse!

S

santeri kalliomaki

Guest
I need to make my ragdoll move towards mouse.

If my cursor is in right side of the ragdoll it does what I want it to do

but if the cursor is in left side the ragdoll turns upside down. o_O

Code of the dragdoll:

///CREATE RAGDOLL
//Torso
var Torso = instance_create(x,y,oBody_parts);
with Torso
{
sprite_index = spTorso;
event_user(0);
global.torso = id;
}

//Top
var Neck = sRagdoll(spNeck,Torso,0,-50,30,false);
var Head = sRagdoll(spHead,Neck,0,-50-20,30,false);
var Stomach = sRagdoll(spStomach,Torso,0,50,30,false);
var Pelvis = sRagdoll(spPelvis,Stomach,0,50+50,30,false);

//Arms
var Arm_L = sRagdoll(spArm,Torso,50,-20,90,true);
var Arm_R = sRagdoll(spArm,Torso,-50,-20,90,true);
var Forearm_L = sRagdoll(spArm,Arm_L,50+60,-20,90,true);
var Forearm_R = sRagdoll(spArm,Arm_R,-50-60,-20,90,true);
var Hand_L = sRagdoll(spHand,Forearm_L,50+60+60,-20,30,true);
var Hand_R = sRagdoll(spHand,Forearm_R,-50-60-60,-20,30,true);

//Legs
var Leg_L = sRagdoll(spLeg,Pelvis,20,50+50+20,90,false);
var Leg_R = sRagdoll(spLeg,Pelvis,-20,50+50+20,90,false);
var Shin_L = sRagdoll(spShin,Leg_L,20,50+50+20+70,90,false);
var Shin_R = sRagdoll(spShin,Leg_R,-20,50+50+20+70,90,false);
var Foot_L = sRagdoll(spFoot,Shin_L,20,50+50+20+70+70,90,false);
var Foot_R = sRagdoll(spFoot,Shin_R,-20,50+50+20+70+70,90,false);

//Change depth (Arms and Legs in front of Body)
Arm_L.depth = -1;
Arm_R.depth = -1;
Forearm_L.depth = -1;
Forearm_R.depth = -1;
Hand_L.depth = -1;
Hand_R.depth = -1;
Leg_L.depth = -1;
Leg_R.depth = -1;
Shin_L.depth = -1;
Shin_R.depth = -1;
Foot_L.depth = -1;
Foot_R.depth = -1;

instance_destroy();

Code of ragdoll facing direction:

if physics_test_overlap(x, y, 0, o_box){
phy_speed_x=0
phy_speed_y=-10
}

var ldx = lengthdir_x(0, mouse_x);
var ldy = lengthdir_y(0, mouse_y);
with(oBody_parts)
{
phy_rotation = point_direction(phy_position_x,phy_position_y,mouse_x,0)
direction = phy_rotation = 0
image_angle=direction.x
}

if x < mouse_x
image_xscale=+1
else
image_xscale=-1

I think the problem is somewhere in there. Thank you for reading and hopefully helping me out! :p
 
Top