Alright, let's learn a bit! First off, what we need is some way for the two objects to communicate. Honestly, this is often the hardest thing for new users to wrap their head around, so hopefully I can shed some light on that. Right now you have a shadow, and you want it to be able to communicate with it's parent, the plane. The thing is, the only way you can really do that is to search for its parent. Even then, if there were more than 1 shadow, or more than 1 planes, how would each shadow know which plane was it's parent? How would each plane know which shadow was its child? The answer is simple: we tell them.
Code:
shadow = instance_create( x, y + 400, obj_plane_shadow )
In this case, wee call this bit of code from the create event for the plane. You should be familiar with the varA = varB syntax if you've gotten this far so I'm not going to bother explaining that, what is important is that the instance_create function is returning the ID of the shadow you just created. All we have to do is 'capture' that by assigning it to a variable, the imaginatively named 'shadow'. Now that is done there are
a lot of things we can accomplish. For example, how can you tell the shadow which plane is it's parent? We tell it. Now that we know who the child is, the plane can tell it whatever it wants.
The section of the manual, Addressing Variables in Other Instances, is the section you need to read. It should give you a better understanding of how and why this works. Instead, let's talk about why the child shadow probably doesn't need to know who its parent plane is. Generally, especially if you are just learning, you have no idea what order instances update in. Sure, you
should know they'll update during the step event if you put code there, but how do you know which code runs first? The plane or the shadow? For example, if the shadow sets its position, but updates before the plane, its position will be set for this step. When the plane processes, it may move because of user input or other actions. Since the shadow already updated, it won't change position again until it updates
next step. This means the shadow will not follow the plane smoothly. To fix that you just need to make sure the shadow is always updated
after the plane, and the easiest way to do that is to have the plane update it. Since the shadow is, weakly speaking, a part of the plane, we can just have the plane do all the work.
One last thing, you
also need to make sure parents delete their children! If the parent plane is destroyed, you should make sure it
also does:
Code:
instance_destroy( shadow )
During it's destroy event, otherwise you'll have a shadow with no plane!
Hope that helps and good luck!