saving objects in variables

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.

    <img src="https://dl.dropboxusercontent.com/u/93191212/Capture.PNG" border="0" />

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

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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here is the Capx file. This seems very basic but cant seem to get this to work.

    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.

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)