SOLVED creating instance based on cardinal direction.

i'm not sure if im doing it right but, it somehow works. I have 4 sprites for each direction( so i dont have to flip the sprite in code)

and i tried to find the direction using collision mask, is there any other better way? i've tried my best looking up cardinal direction and collision masks. but im not sure how to see if im on the "left side" of a square exactly, and not in the middle.
here is an example wich kinda works for left side.
GML:
//collision
if (place_meeting(x,y,pCollision)) and (image_index != 0)
{
    
    //left
    if (place_meeting(bbox_left,bbox_left,oEarthtexture))
    {
    instance_create_layer(x,y,"Projectiles",oEarthblockHitBox);
    }

   
   
    instance_destroy();
}
 

NightFrost

Member
What exactly are you trying to accomplish? I'm looking at the code but it doesn't give much clue. If you want to create something based on character facing, you can save the last direction moved and use that as a guide.
 
What exactly are you trying to accomplish? I'm looking at the code but it doesn't give much clue. If you want to create something based on character facing, you can save the last direction moved and use that as a guide.
oh im so sorry, ok so when this object, (wich is sent flying) it will hit the object called oEarthtexture

from there i want it to create the object oEarthblockHitBox.

i've already accomplished this. At first i just flipped the object first, so it faced my direction.
But i want a smooth either left, right, top, bottom, faced sprite. being created away from the object it hits.

i've sort of got the solution so far. But the only thing i need is How do i recognize the side of the object.

so if the object i sent flying hit the left side of the object. the object that goes to the left, gets created. (from the same point it hit)
and so on the other directions too.
i apologize for any confusion.
 
I don't understand why you would be using your x-coordinate as a y-coordinate.
Oh wait so i need to just set it the y_coordinate to y and it works fine?
it seems to work this way so, thank you guys anyway, such a silly problem. spent way too much time trying to figure it out.


i thought it didn't work at all, because i realized when it check bbox_left, it worked when i hit from the right. so i just had to flip everything
 
Last edited:
Top