• 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!

Legacy GM [SOLVED] Checking another instance's values.

L

Latté

Guest
In the game, there are certain objects that are supposed to be considered rounded and when certain other objects (like rocks) fall onto them, they should roll off.

I tried making every object have a true or false variable called "rounded." Then, I was going to make the rocks roll to the side if rounded was true for the object beneath them. However, I don't know how to make the rocks check the values of an instance at a specific position.

Hopefully that's enough information.
 
E

ericbunese

Guest
Hi, try using instance_place(x, y, obj); or instance_position( x, y, obj ); to get the instance id to a variable.
Ex: var p = instance_position(x, y, rock);
if (p.rounded)
{
...
}

Hope that helps.
 
L

Latté

Guest
It works! But only for rocks. There are a few other objects that are also defined as rounded. Is there a way to check for any object? Or will I have to do something like this:
Code:
var a = instance_position(x, y, rock);
var b = instance_position(x, y, ...);
var c = instance_position(x, y, ...);
if (a.rounded || b.rounded || c.rounded)
{
...
}
 
E

ericbunese

Guest
Yes, create an object that will represent everything you must test for, and make it be these objects's parent.

Use the parent as the third argument to instance_position or instance_place.

This image will help you understand it.
http://imgur.com/a/erflb

All you'll have to do is
Code:
var p = instance_position(x, y, parent);
if (p.rounded)
{
 ...
}
 
L

Latté

Guest
Thanks so much for the help, I'll mark this topic as solved now.
 
Top