Parent error, Space Mods tutorial

Grinds

Member
Hello everyone,

I am currently following the "space mods" tutorial series.

At the moment i'm at the "Space Mods - GML - Enemy Factions (2/3) - GameMaker Studio 2" section.
Here exactly :

I have a little problem, when I try to shot, my ship freezes and what I shot stays in place.
The problem apparently comes from the collision use of the parent "obj_faction" with the bullet object but I really don't understand where my mistake is.


Here the behaviour with the parent "obj_faction" and the one with a smaller parent (the asteroid one) :
Here the behaviour with no collisions with parents and the one with collisions with the parent "obj_faction" but no code in it :
Thanks in advance.
 
Last edited:

Grinds

Member
of course, here it is :) :
  • Step ship event (where my bullet is created):
I actually don't use script function to have a simpler code​
GML:
if(keyboard_check(vk_left)){
    image_angle = image_angle +5
    show_debug_message("image_angle: "+string(image_angle))
}
else if (keyboard_check(vk_right)){
    image_angle = image_angle -5
   //show_debug_message("image_angle: "+string(image_angle))
}

if(keyboard_check(vk_up)){
    motion_add(image_angle, 0.05)
    show_debug_message("speed: "+string(speed))
}

if(keyboard_check_pressed(vk_space)){
    //show_debug_message("x: "+string(x)+",y: "+string(y))
    //create_bullet(image_angle,bulletSpd,faction,id)
    var inst = instance_create_layer(x,y,"Instances",obj_bullet1)
    inst.image_angle = image_angle
    inst.faction = faction
    inst.creator = id
    inst.direction = image_angle
    show_debug_message("ship : id: "+string(id)+", faction: "+string(faction))
}
show_debug_message("ship : id: "+string(id)+", faction: "+string(faction))

move_wrap(true,true,sprite_width/2)
  • Create bullet event
GML:
speed = 6
creator = undefined
faction = undefined
  • Step bullet event
GML:
if(!point_in_rectangle(x,y,global.cameraX,global.cameraY,
global.cameraX+global.cameraWidth,
global.cameraY+global.cameraHeight)){
    show_debug_message("point_in_rectangle")
    instance_destroy()
}
  • obj_faction collision with bullet event
GML:
if(other.id == creator){
    //show_debug_message("bullet : other.id==creator")
    exit
}
//show_debug_message("11x: "+string(x)+",y: "+string(y))
if(other.faction == faction){
    //show_debug_message("bullet : other.faction == faction")
    exit
}
instance_destroy()

with(other)
    event_perform(ev_other, ev_user1)
 

Grinds

Member
You say that this is the obj_faction collision event with the bullet. Think about which of those is "self" and which of those is "other" in this context.
I have think about it but i don't get it.
For example why when i create an empty collision event with my obj_faction, the movement of my ship and my shooting stops working (example in space mods - parent bug part 2/2).
 

Nidoking

Member
I have think about it but i don't get it.
For example why when i create an empty collision event with my obj_faction, the movement of my ship and my shooting stops working (example in space mods - parent bug part 2/2).
Why did you create an empty collision event with your obj_faction? What were you hoping to achieve?

If you don't understand the concept of self, then maybe you're trying to do something too advanced for your skill level. You might need to look for some simpler tutorials.
 

Grinds

Member
Thank you but I don't think you understand my problem, this empty collision is there to show where my problem is.
for me what I wrote is supposed to work.
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Are any of your objects marked as solid? Collisions with solid instances will halt any form of movement.
 
Top