woods
Member
ive got some really derpy floppy cows running around this farm..
my issue.. obj_cow gets hung up when moving within 1 cell north of obj_block
//obj_block has no code.. is a simple placeholder for collision check under the fences and walls and such.
what gets me is my movement code is the same for all 4 directions NESW .. they wander around just fine out in the field... next to the north fence, east fence, west fence, next to no fence, everywhere is golden... except when they get on the north side spot of the fence.
my first thought was sprite mask issue .. so i squeezed the mask in a few pixels thinking that might fix it... nope. that didnt help.
ive looked and looked thinking i had a x=+32 where i needed a y-32 .... i triple checked that bit.. i cant see a problem..
ive put a couple days into this and have pulled out most of my hair trying to figure it out...
i know its some simple little thing that ive forgotten or havnt learned yet....
any help would be awesome
obj_cow
create event
obj_cow
step event
ive probably over-engineered the movement bit .. but this is how i got it to kinda work in the 32x32 grid...
sidenote.. if there is an easier way to make this happen.. tips in that area would be nice too but that would just be a bonus ;o)
my issue.. obj_cow gets hung up when moving within 1 cell north of obj_block
//obj_block has no code.. is a simple placeholder for collision check under the fences and walls and such.
what gets me is my movement code is the same for all 4 directions NESW .. they wander around just fine out in the field... next to the north fence, east fence, west fence, next to no fence, everywhere is golden... except when they get on the north side spot of the fence.
my first thought was sprite mask issue .. so i squeezed the mask in a few pixels thinking that might fix it... nope. that didnt help.
ive looked and looked thinking i had a x=+32 where i needed a y-32 .... i triple checked that bit.. i cant see a problem..
ive put a couple days into this and have pulled out most of my hair trying to figure it out...
i know its some simple little thing that ive forgotten or havnt learned yet....
any help would be awesome
obj_cow
create event
Code:
image_speed = 0.1
isWalking = true
counter = 0
step event
Code:
/// move random
counter = counter+1
if isWalking = true and counter = 60
{
//pick direction
var number=irandom(8)
//move and change sprite
if (number>3)
{
speed=0; image_speed=0.1; //idle
}
if (number==3) and (!place_meeting(x+32,y,obj_block))
{
motion_set(0,0.6);image_speed=0.2; sprite_index=spr_cow_right; //east
}
else
if (place_meeting(x+32,y,obj_block))
{
speed=0;image_speed=0.1; //idle
}
if (number==2) and (!place_meeting(x-32,y,obj_block))
{
motion_set(180,0.6);image_speed=0.2; sprite_index=spr_cow_left; //west
}
else
if (place_meeting(x-32,y,obj_block))
{
speed=0;image_speed=0.1; //idle
}
if (number==1) and (!place_meeting(x,y-32,obj_block))
{
motion_set(90,0.6);image_speed=0.2; sprite_index=spr_cow_up; //north
}
else
if (place_meeting(x,y-32,obj_block))
{
speed=0;image_speed=0.1; //idle
}
if (number==0) and (!place_meeting(x,y+32,obj_block))
{
motion_set(270,0.6);image_speed=0.2; sprite_index=spr_cow_down; //south
}
else
if (place_meeting(x,y+32,obj_block))
{
speed=0;image_speed=0.1; //idle
}
move_snap(32,32);
//reset move counter
counter = 0;
}
ive probably over-engineered the movement bit .. but this is how i got it to kinda work in the 32x32 grid...
sidenote.. if there is an easier way to make this happen.. tips in that area would be nice too but that would just be a bonus ;o)