N
Nuthole
Guest
ok so i need to make the image angle of objectA the direction of objectB, but when i do "launch = image_angle" on objectA, objectB does not understand the "launch" variable. how do i make objectB understand?
objectA.launch = image_angle
objectB.image_angle = launch
Hi, thank you so much! i have been having this problem for actual days now and this is the first thing that actually worked, the working code is: motion_add(objectA.launch, 17) for anyone who sees this in the future, thanks!Could you clarify a bit? What is the variable launch for? Does it store the objects direction? You can call out variables from other objects by stating the object before the variable.
If you wanted objectA’s image_angle to equal objectB’s launch direction you could type:
If objectB is calling the code...
If objectA is calling the code...Code:objectA.launch = image_angle
Code:objectB.image_angle = launch
var inst = instance_create_layer(x,y,"layer",objectB); // Store the instance ID of the objectB instance that was just created in a temp variable called "inst"
with (inst) { // Now we use with() to tell muddle with the insides of the instance of objectB that was just created, using the previously created temp variable holding said instance ID "inst"
launch = other.image_angle; // If this code is being run from within objectA then other in this circumstance will refer to objectA, so we can use other.image_angle to get the image_angle of objectA and set an instance variable called launch within objectB to it.
}
motion_add(launch,17);
While the members before you have some work to do when it comes to objects vs. instances, looks like you have some work to do as well when it comes to event timing. If you put the motion_add() line in the Create event of objectB, it will still trigger too early.What you should be doing is storing the instance ID of objectB when it is being created and then using that ID to tell the instance of objectB what to do, something like this (this is from within objectA):
Then you can simply do:Code:var inst = instance_create_layer(x,y,"layer",objectB); // Store the instance ID of the objectB instance that was just created in a temp variable called "inst" with (inst) { // Now we use with() to tell muddle with the insides of the instance of objectB that was just created, using the previously created temp variable holding said instance ID "inst" launch = other.image_angle; // If this code is being run from within objectA then other in this circumstance will refer to objectA, so we can use other.image_angle to get the image_angle of objectA and set an instance variable called launch within objectB to it. }
Within objectB and it will aim wherever the image_angle of objectA was facing when objectB was created.Code:motion_add(launch,17);
with (instance_create_layer(x, y, "layer", objectB)) {
launch = other.image_angle;
event_user(14);
}
// User event 14
motion_add(launch, 17);
with (instance_create_layer(x, y, "layer", objectB)) {
motion_add(other.image_angle, 17);
}