Qlak
Member
Hello!
I'm having trouble with (probably) lengthdir. I spent so much time on it, but I just can't figure out what I am doing wrong.
I thought that maybe someone can give me the reason this is happening.
Basically I was trying to draw circles in front of the character, as hands and I used lengthdir x and y and image_angle to place them in the right place and so they turn with character.
It works, but for some reason they move slightly and its a bit annoying. When I look up, they are a little closer to the character, than when I look right or down. They also tend to move a little to the side:
Normal placement:
And with circles moved to the middle:
Some more info:
I ran out of ideas how to fix this, and it should be really simple... Just like target and aiming system in other games, it shouldn't move it should go around and move with character sprite.
Do you guys have any idea what could be the reason behind this?
Thanks in advance
Cheers!
I'm having trouble with (probably) lengthdir. I spent so much time on it, but I just can't figure out what I am doing wrong.
I thought that maybe someone can give me the reason this is happening.
Basically I was trying to draw circles in front of the character, as hands and I used lengthdir x and y and image_angle to place them in the right place and so they turn with character.
It works, but for some reason they move slightly and its a bit annoying. When I look up, they are a little closer to the character, than when I look right or down. They also tend to move a little to the side:
Normal placement:
GML:
var rightHandX = x + lengthdir_x(14, controllerAngle + 45);
var rightHandY = y + lengthdir_y(14, controllerAngle + 45);
var leftHandX = x + lengthdir_x(14, controllerAngle - 45);
var leftHandY = y + lengthdir_y(14, controllerAngle - 45);
GML:
var rightHandX = x + lengthdir_x(14, controllerAngle);
var rightHandY = y + lengthdir_y(14, controllerAngle);
var leftHandX = x + lengthdir_x(22, controllerAngle);
var leftHandY = y + lengthdir_y(22, controllerAngle);
Some more info:
- The controllerAngle variable is basically image_angle. So it works the same.
- It is done in the draw event.
- The sprite origin is set to middle center.
- Tried changing circle size and also had this problem.
- (added after reply) The character is properly centered in the sprite with equal number of pixels to the sides.
- (added after reply) Original sprite is 129x129 so I have a "center pixel" for top-down game, and aiming convinience, but I checked for 128x128 as well and it did not work as well.
- (added after reply) Seems like x and y of the character do not match sprite origin for some reason. Can be seen on screenshots with added red lines from the x and y position, further in this topic.
- (added after reply) The little red dot on Character's Head is not made by GMS - it is drawn on Character Template Sprite to see the center of the character.
I ran out of ideas how to fix this, and it should be really simple... Just like target and aiming system in other games, it shouldn't move it should go around and move with character sprite.
Do you guys have any idea what could be the reason behind this?
Thanks in advance
Cheers!
Last edited: