• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Parent position

C

cedart

Guest
Hello :)

I'm trying to learn game maker after unity and construct, but some basic functions seem not to be present.. :/
When i put an object in the scene and parent it with an other, I would like that its position change relatively to the parent.
For exemple, I have an empty object that make smoke, and a ship. I put the empty on the reactor in the room, and i want it to follow the ship. But I can't do that :)
For the moment I make the object following by putting the coordinates by hand, like this :

Code:
x = ship.x - 45
y = ship.y + 20
But that's weird and maladjusted :/
Did someone have a simple solution for that please ? :)

Thanks so much in advance !

(GM seems to be a really good software, but some things are really weird and boring ^^)
 
H

heyimdandan

Guest
Weird and maladjusted? Does it work though, because that's a fairly basic piece of code!
 
C

cedart

Guest
Thank you for your fast responses :)

Bingdom that's works, here is my code.

In the empty "create" :
Code:
len = point_distance(x,y,Ship.x,Ship.y);
dir = point_direction(Ship.x,Ship.y,x,y);
And in the empty "step" :
Code:
x = Ship.x + lengthdir_x(len,dir);
y = Ship.y + lengthdir_y(len,dir);
So I don't need to calculate the coordinates, but I really find surprising to have to script a basic thing like this ^^'. In all softs on this planet, you just parent two objects and they move together :)

Thanks :)

PS : Nothing to do but do you know how to disable and event or an action ?
 

Bingdom

Googledom
PS : Nothing to do but do you know how to disable and event or an action ?
For as far as i'm aware, i don't think there is a way to disable events during gameplay. What you can do is run a 'if' statement like this:
Code:
if (can_follow) {
    //Lengthdir functions here
}
And set can_follow to false whenever you want (make sure you initialize it in the create event!), and the object will stop following.
 
Last edited:
C

cedart

Guest
The parent propertie is not for the position, but for sharing code etc. So that's really cool, and really bad at the same time :)

I would like to disable events and actions more for the development, to try an action, disable it, enable an other, etc, but i don't know if it's possible.
 

TsukaYuriko

☄️
Forum Staff
Moderator
If you're asking whether it's possible to stop inheritance: Yes. Adding an event (and any sort of action - can be an empty comment) to a child will prevent the parent event from being inherited... unless you explicitly call event_inherited inside said event.
 
Top