Legacy GM how can i collide with drawn objects

S

santeri kalliomaki

Guest
I dont know how to collide with my "gun"
draw event code:
if gun !=-1{
draw_sprite_ext(spr_sword, gun, x + lengthdir_x(4, point_direction(x, y, oBody_parts.x, oBody_parts.y)), y + 4 + lengthdir_y(4, point_direction(x, y, oBody_parts.x, oBody_parts.y)), 1, 1, point_direction(x, y, oBody_parts.x, oBody_parts.y)+90, c_white, 1);}
 

TheouAegis

Member
Why do you need to collide with the gun? Typically people ignore collisions with guns.

To collide with any drawn sprite, you'd need to use something like rectangle_in_rectangle() or collision_rectangle() and use the bounds of the weapon's sprite for the coordinates you define in the function.
 
S

santeri kalliomaki

Guest
Why do you need to collide with the gun? Typically people ignore collisions with guns.

To collide with any drawn sprite, you'd need to use something like rectangle_in_rectangle() or collision_rectangle() and use the bounds of the weapon's sprite for the coordinates you define in the function.
I'm making a multiplayer ragdoll fighting game and now the collision works and i need it to work because it's a sword and it needs to do damage to other players but now it destroys players own hand... :(
 
S

santeri kalliomaki

Guest
Post your code you ended up using. I can guess what's wrong but it should be easier to tell with your code.
with oBody_parts{
if gun !=-1{
collision_rectangle(50, 50, 200, 100, gun, false, false){
instance_destroy();}}
}
 
S

santeri kalliomaki

Guest
You need an if in front of collision_rectangle().

Also i think maybe you need to refer to gun as other.gun in that code.
It works but once hands disappeared. Is is because the player can have swords in his both hands? Maybe this happens if the hands touch each other.
 

TheouAegis

Member
Do you have anything in place that lets each body part know which person it belongs to? If the body part and the sword/gun belong to the same person, they shouldn't be destroying each other.
 
Top