#Top down melee attacks aim
1 messages · Page 1 of 1 (latest)
Sorry, I forgot to mention it makes an object, should I give you the code for that?
Well it sets an alarm for 9 seconds but then it destroys itself once its created, don't know if that'll help though
I mainly want the attack to aim in the direction you click though, currently it sets the object in the direction you click, but it doesn't change the sprite to face where you clicked
then go image_angle = dir in the object that is linked to the sprite
Alright I'll give this a shot, thanks for the help!
Okay, so it didn't work out well, either it would say that the variable "dir" was not described if I put it in the hitbox object, and if I put it in the player, the player would face the direction of the hitbox, and ideas on how to fix this?
Nevermind I have it figured out, the only problem is that it continues to look towards my mouse after its created, and idea on how to lock an image_angle in place?
not set it
Well it doesn't have set before image angle, here have a look at the code
if (mouse_check_button_pressed(mb_left))
{
var playerCenterX = x + sprite_width / 9;
var playerCenterY = y + sprite_height / 6;
var dir = point_direction(playerCenterX, playerCenterY, mouse_x, mouse_y);
var LEN = 32;
var hitboxX = lengthdir_x(LEN, dir) + playerCenterX;
var hitboxY = lengthdir_y(LEN, dir) + playerCenterY;
var hitbox = instance_create_depth(hitboxX, hitboxY, depth, Ohitbox);
with (instance_create_layer(x,y,Ohitbox,Ohitbox))
{
direction = other.image_angle;
image_angle = direction;
}
hitbox.creator = id;
}
Heres the player event
And the hitbox event
image_angle = point_direction(x,y,mouse_x,mouse_y);
the image_angle = point_direction(x,y,mouse_x,mouse_y); is making it point towards your cursor every frame. if you dont want it to then get rid of the line.