Access to Specific Instance via UID Issue

Get help using Construct 2

Post » Tue Jun 12, 2012 12:31 pm

Hi,

I'm trying to access a specific object instance (in this case a rocket) and position it depending on the position of my ship - Just for context this is to show that the ship is currently carrying the rocket.

My understanding is that the first Rocket I create will be assigned a UID of 0. Currently I'm creating a single Instance of Rocket, when I position all Rocket objects over my ship the Rocket appears but if I specify the Rocket with a UID of 0 it doesn't appear. Note I'm not deleting any rockets at this point so this shouldn't be the issue.

My Events look like this

Works fine

   Player | Weapon = "Rocket"
   Action -> Rocket | Set position to (Player.X, Player.Y)

Rocket not positioned on Ship

   Player | Weapon = "Rocket"
&& Rocket | Pick Instance with UID 0
   Action -> Rocket | Set position to (Player.X, Player.Y)


Apologies if this has already been answered, I've been through everything I could find on Unique, Instance ID's in the forums and couldn't see what I am doing wrong.

Many thanks
Ben
B
4
Posts: 3
Reputation: 306

Post » Tue Jun 12, 2012 12:41 pm

Hi Ben, I dont think the there is a UID with 0.
Try to use the IID (Instance ID) instead which is proportional to the count of Objects in your scene.
You picke a Object by its IID by using:

System -> Pick Nth instance

e.g If you have 2 Spaceships and 4 Rockets
There are
Spaceships IID 0 - 1
Rockets IID 0 - 3
but Spaceship with IID of 0 may have any random Unique ID (It's not totaly random but kind of)Fabian Schempp2012-06-12 12:43:22
B
18
S
3
G
3
Posts: 29
Reputation: 2,724

Post » Tue Jun 12, 2012 12:41 pm

UID means Unique ID
IID means Instance ID

UID are number assigned to all the object of your layout. Two objects will never have the same UID and if you create a Rocket you'll get the next UID of the whole project
Thus UIDs are IDs in a per layout basis

IID are IDs in a per instance basis and it looks like what you described.
To pick an instance by its IID the proper expression is a system expression. System: pick nth instance


(darn been ninja'd)Yann2012-06-12 12:42:34
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jun 12, 2012 2:18 pm

Thanks, that helps alot. Looks like I'd misread another forum and confused UID's and IID's.

I've just found some really useful instance reference in this thread http://www.scirra.com/forum/how-do-ifrequently-asked-questions_topic45416.html

Thanks again for the help
Ben
B
4
Posts: 3
Reputation: 306

Post » Tue Jun 12, 2012 2:42 pm

Might want to check out the relevant manual entry for UID and IID too.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests