saving objects in variables

Get help using Construct 2

Post » Tue Oct 01, 2013 2:14 am

Hello everyone i just picked up Construct 2 and im very new to coding. I have a small test project that I am stuck on. Is there are way to store an object in a variable? Im just adding some sprites on screen and i want to be able to have the "enemy" sprite move towards a random target. I have played with random and choose but keep getting stuck since i cant use the object name in the expression. Im sure there is an easy way to do this that i have overlooked but cant seem to find anything specific in the docs.

Here is what im trying to do. Top, center, and bottom are just simple sprite objects. they have the bullet behavior and are moving i just can get them to angle in the right direction.

sgtdrpepper2013-10-01 03:02:43
B
3
Posts: 3
Reputation: 181

Post » Tue Oct 01, 2013 3:24 am

You have the UID in the variable, now all you have to do is Pick by UID and the object will be "picked" inside the event that picked it.

All objects are "picked" until you use an event to filter it down to the one or ones you want "picked" then the actions inside the event act on those objects only.
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Tue Oct 01, 2013 3:27 am

You might have more luck by posting a link to the .CAPX. I can't figure out what you are trying to do. Or more specifically, why you have an enemy chasing a random bullet.
B
17
S
4
Posts: 31
Reputation: 1,600

Post » Tue Oct 01, 2013 3:35 am

Here is the Capx file. This seems very basic but cant seem to get this to work.

https://dl.dropboxusercontent.com/u/93191212/mytest.capx

Also i read about the pick by UID option but i dont see that listed as an option in the system events.sgtdrpepper2013-10-01 03:39:44
B
3
Posts: 3
Reputation: 181

Post » Tue Oct 01, 2013 4:30 am

https://dl.dropboxusercontent.com/u/85412219/forumposts/PickingRandomSprite.capx

The Pick by UID is in the Sprite, not system.

I would have put them all in a family and picked once on the family, but I'm not sure if you have the free version or not. (it doesn't support them.
Another option is to put all enemies as different animations of the same sprite, them you could just pick that one sprite.
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Wed Oct 02, 2013 1:01 am

Thank you I will check out your example. I am still using the free version of the software so families are not an option yet.
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: ksiads and 6 guests