NPC Collision
Posted: Sun Mar 28, 2021 8:57 pm
Hey. I hope everyone is well. I come to the community with another simple concept. I have created NPC1 and NPC2 objects as well as a Player object... On my player object I have created character controls that go as follows...
All of the collisions for the collision map work well... My problem is with the player getting stuck on the NPC characters. When they collide my player gets stuck ESPECIALLY if I add collision checks for "up" and "down" on top of these "left" and "right" collision checks.
Is there a better way for me to do this? Am I heading into the right direction? I wouldnt mind even getting rid of collisions on NPC characters all together if I had the availability to allow the player object in front of or behind objects based upon where they are on the X axis..
If anyone could shoot some advice my way, that would be amazing! Thanks so much!
This is to look out for the other NPC characters as well as as the other layers in the level for a collision map.If Pad.Held.Right
if !Sprite_Collision([Me], Get_Single_ID(NPC1))
if !Sprite_Collision([Me], Get_Single_ID(NPC2))
if(PA_EasyBgGetPixelCol(Top_Screen, 3,[X] + [Width], [Y] + [Height]/2)!= PA_RGB(0,0, 0)){
If !Object_Under_Point(Top_Screen, [X]+[Width], [Y]+[Height]/2, NPC1)
[X] += 2;
End if
End if
End if
End if
}
If Pad.Held.Left
if !Sprite_Collision([Me], Get_Single_ID(NPC1))
if !Sprite_Collision([Me], Get_Single_ID(NPC2))
if(PA_EasyBgGetPixelCol(Top_Screen, 3,[X], [Y] + [Height]/2)!= PA_RGB(0,0, 0)){
If !Object_Under_Point(Top_Screen, [X]+[Width], [Y]+[Height]/2, NPC1)
[X] -= 2;
End if
End if
End if
End if
}
All of the collisions for the collision map work well... My problem is with the player getting stuck on the NPC characters. When they collide my player gets stuck ESPECIALLY if I add collision checks for "up" and "down" on top of these "left" and "right" collision checks.
Is there a better way for me to do this? Am I heading into the right direction? I wouldnt mind even getting rid of collisions on NPC characters all together if I had the availability to allow the player object in front of or behind objects based upon where they are on the X axis..
If anyone could shoot some advice my way, that would be amazing! Thanks so much!