Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
The easiest case is to store the previous X and Y positions of the object from the frame just before and subtract those values from the current coordinates. If you use the abs()-function you will always get a positive number, e.g.
If you're dealing with a main object spawning something else (ie. projectiles) you can actually get the instance id from instance_create():
This works because instance_create() returns the instance id of the newly created thing. Functions that return instance ids are basically what you're after here, and there's a lot of them, like instance_nearest(), instance_place(), or instance_find(). If you want to index instances easily, having a control object that tracks all instances of an object on a list or array might prove useful, so that could be worth investigating depending on the situation. The with() statement might also help you here; my point is there's a lot of ways, and the best one will depend on your situation.
That's the hard part. Once you have the instance id, it's really simple to find it's hspeed, vspeed, direction, or any other variable local to it. Working with our previous example of TrackingObj:
The important thing to take from this is "thing.variable". It's a very important, vital thing to know! (Even globals use this, with "global" taking the place of your instance ids as its own, nebulous thing.) So long as you remember that rule, the hard part is generally just going to be deciding which lookup method serves your needs best.