Kyon
Member
Goodevening!
I'm having a lot of trouble working with lengthdir.
I want an object attached to the player, but with a 32 offset en the direction is towards the mouse.
This is my script at the moment:
Now this works perfectly. The item is at the right spot where I want it to be.
It looks like this:
The item is the oillamp.
I have made that the arm of the player follows the mouse, but stops at a certain degree.
Like so:
This works, but I am having trouble with doing the same with the oillamp item.
I cant seem to clamp the lengthdir to the 44 degrees the arm is clamped to.
I have tried adding stuff like this:
But this made the item not do anything anymore.
Sorry for my english, it's hard to explain.
I hope someone understands and can help me.
Thank you
I'm having a lot of trouble working with lengthdir.
I want an object attached to the player, but with a 32 offset en the direction is towards the mouse.
This is my script at the moment:
Code:
//ITEM THAT YOU HOLD
itemdir = point_direction(x,y-22,mouse_x,mouse_y);
if image_xscale=1{
itemx = x + lengthdir_x(32,itemdir-26);
itemy = y-22 + lengthdir_y(32,itemdir-26);
}
if image_xscale=-1{
itemx = x + lengthdir_x(32,itemdir+26);
itemy = y-22 + lengthdir_y(32,itemdir+26);
}
It looks like this:
The item is the oillamp.
I have made that the arm of the player follows the mouse, but stops at a certain degree.
Like so:
Code:
angle = point_direction(x,y-22,mouse_x,mouse_y);
if image_xscale=1{
//arm
if angle<=22 or angle>=344{
armangle=angle;
} else if angle>22 && angle<180{armangle=22;}
else if angle <344 && angle>180{armangle=344;}
}
...
I cant seem to clamp the lengthdir to the 44 degrees the arm is clamped to.
I have tried adding stuff like this:
Code:
if itemy<-19{itemy=-19; itemx=31;}
if itemy>0{itemy=0; itemx=23;}
Sorry for my english, it's hard to explain.
I hope someone understands and can help me.
Thank you