Targetting specific instances of objects

Get help using Construct 2

Post » Mon Apr 15, 2013 8:18 am

[QUOTE=BluePhaze] Thanks @R0J0hound that makes sense. How would you assign the random to it? What I have currently now is:

Block > Pick Instance with UID Random(Block.UID)
---- System > Set Target to block.UID

For some reason though, this still does them all in order. I have tried other parameters to the Pick Instance with UID like Random(0,122), etc... but it does not work. It just sits there and nothing happens. Any better expression to plug into when grabbing the UID to really get a random (but existing) UID from the 100 blocks I Have on the screen?

Thanks![/QUOTE]

The idea would be to pick a random instance of block, assign it's UID to target variable, and use that to refer to the target block in the future.

So do something along these lines:

pick random block
.. target = block.uid

pick block by uid target
.. shoot

B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Apr 15, 2013 8:29 am

@vee41

The pick random block piece is the one causing the issues. Using "System > Pick Random instance" works, but for some reason it ignores some of the blocks. Using System > Pick nth instance for some reason picks them in order and still skips blocks. Using "Block > Pick Instance with UID Random(Block.UID)" also works but again does them all in order even though I am specifying random... But at least it does get all the blocks now and I am not left with 4 or 5 that it just ignores all together.

The goal is to clear them all, and do them in a random order. So random block is picked, all enemies target it, once it is destroyed a new random block is picked. Here is the current and 14th or so iteration of the logic, I have scrapped generating the grid of block on the fly because it caused random oddness here and there. Currently I Have the state and the animation frame tied together so that as the block is damaged the state changes which updates the animation frame. Note that I have also added an event that sets the state and animation frame of the block as soon as it is picked as the target so that I can tell which one is being targeted before it gets hit. This is just to allow me to make sure that the block being targeted is the same for all enemies at any particular time. I also have a shot variable to control the number of shots an enemy can take so that the blocks do not get cleared out to quickly.

BluePhaze2013-04-15 08:31:47
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Mon Apr 15, 2013 8:52 am

The randomization event "Pick instance with UID Random(Block.UID)" does not really make any sense. You should use 'pick random instance' event like you did before, and everything else should work.

If you use "Pick instance with UID" event, you'll need to enter an UID of exiting block to make it work. Right now, you are randoming a number from 0 to whatever UID first picked block has.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Apr 15, 2013 5:19 pm

Doesn't make sense to me currently either. I got it working with "Pick Random Instance" but it skipped blocks for some reason, at the end there would be 4-6 blocks that it just totally ignores. With "Pick Instance with UID" it works, but it does them all in order by UID.

Using @R0J0hound advice I am trying to make it work with "Pick Instance with UID" on the block object. The Block object doesn't have a pick Random instance like the system object does...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Mon Apr 15, 2013 7:18 pm

Here's a capx since I admit there is some ambiguity with what I typed.
https://dl.dropboxusercontent.com/u/5426011/examples17/target_specific_instance.capxr124
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Mon Apr 15, 2013 9:01 pm

Thanks @R0J0hound that cleared it up. Oddly I had that setup but it wasn't working. I have decided there must be some oddity with my events or with my UID's... But I scrapped it and started from scratch and it works fine just like your sample. Odd. Thanks again for all the assistance on this one!

I am using this logic to create an interactive Under Construction animation for my site. At the load it will do a couple random number generations which will be responsible for picking a set of blocks, a set of enemy types. It will then create the screen and the enemies chosen will destroy the blocks to reveal the company logo and under construction message.

I figured this would be a nice entertaining method that will also allow me to use some of my game characters/assets to be used outside of the game to make the site more personal for those who end up playing my games.

Once the site is finished I will find another way to incorporate it just to keep the entertainment value.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Mon Apr 15, 2013 9:09 pm

@BluePhaze

http://www.scirra.com/forum/125-continuous-preview_topic66367.html?KW=
ImageImageImageImageImageImage
B
93
S
20
G
13
Posts: 1,217
Reputation: 18,996

Post » Tue Apr 16, 2013 12:56 am

@TELLES0808 Thanks that is probably what it was. The ID's from the blocks that were duplicated probably wasn't changing.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Previous

Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt and 22 guests