How do I create and position object to many copied objects

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Ok,

    I'm trying to create an object and position to another multiple copied objects. I tried adding for each as a condition or sub event for the every tick, but nothing seems to work, some times it only shows on one object for this case is the enemy. Any help is very much appreciated. thank you in advance

  • Try this:

    On created obj_Enemy : obj_Enemy spawn obj_enemyGun on layer "game" at image point obj_enemy1.ImagePoint("Gun")

    If the point always at the same place you can use Pin behavior: pin obj_enemyGun to obj_Enemy in the same "on created" event

    If not you have to include instance variables: Set instance variable "parentUID" of the gun to UID of the enemy when enemy created.

    Than every tick for each gun pick an enemy by his UID (=parentUID) and make what you did in your example.

    The reason why your example did not work - because you created only one gun, and no matter how much guns you have they all will be at the place of the first enemy because you did not picked every gun to his specific enemy...

  • Ok,

    I'm trying to create an object and position to another multiple copied objects. I tried adding for each as a condition or sub event for the every tick, but nothing seems to work, some times it only shows on one object for this case is the enemy. Any help is very much appreciated. thank you in advance

    You need to specify which "enemygun" you want where, at the moment in the every tick you set the position of all enemyguns to enemy1 imagepoint.

    This will never work the moment you get more than 1 enemygun. as it will place all of them at the same enemy. You need to either pin the gun to the correct enemy.

    Here is how to do it:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to specify which "enemygun" you want where, at the moment in the every tick you set the position of all enemyguns to enemy1 imagepoint.

    This will never work the moment you get more than 1 enemygun. as it will place all of them at the same enemy. You need to either pin the gun to the correct enemy.

    Here is how to do it:

    Thanks for the reply

    Ok,

    It worked if were talking about multiple copies, the problem now is that I have no control to where I want to position each copy of enemy on the layout, you know the left-click+ctrl copy and drag to where you want to place the copied object on the lay out. Also my main objective is that I want all the guns to behave like a turret pointing at the player.

    I uploaded the capx, so anyone out there can edit it, if they know how to fix it.

    https://www.dropbox.com/s/h850ugb53o3xw0i/spawn%20create%20objects%20to%20multiople%20copied%20objects.capx?dl=0

  • First - You dont need to pin a gun by "Position and Angle" if you want a turret, you need to pin only by "Position" to allow the gun to rotate.

    Second - Try to read about containers: https://www.scirra.com/manual/150/containers

    They are made for making composite objects, exactly what you need.

  • First - You dont need to pin a gun by "Position and Angle" if you want a turret, you need to pin only by "Position" to allow the gun to rotate.

    Second - Try to read about containers: https://www.scirra.com/manual/150/containers

    They are made for making composite objects, exactly what you need.

    Thank you so much for advising to use containers, I literally forgot about this powerful feature in C2. Now everything's working fine.

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