Dynamically selecting child nodes.

  • Hello,

    I was under the impression that adding something to a child object would make it be favored in the selection process of an object, however, this does not seem to be the case for my situation so I am looking for a way to dynamically select an object that is a child of a different object.

    Here is the pseudo code that I have:

    1. I create an enemy controller

    2. When said enemy controller gets created I spawn a sprite for it

    3. Sprite gets added as a child

    4. When the enemy controller collides with a wall I want to run an animation on the enemy

    Simply running the animation on "enemyAnimation" creates a situation where it runs on all instances of enemy animation. So how can I tell construct that I want that to happen only on the child object?

  • 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 use a container. Add the enemy sprite into a container on your controller object, then when you create/spawn a controller, the enemy sprite will be automatically created at the same location. After the create action, in the same event, you can add the enemy sprite as a child of the controller.

    Then for the collision event you need: Controller on collision with XYZ - set Enemy Sprite animation to "collision animation".

  • You need to use a container. Add the enemy sprite into a container on your controller object, then when you create/spawn a controller, the enemy sprite will be automatically created at the same location. After the create action, in the same event, you can add the enemy sprite as a child of the controller.

    Then for the collision event you need: Controller on collision with XYZ - set Enemy Sprite animation to "collision animation".

    Thanks a lot! That makes sense, I knew something helped with the automatic detection of things like this and I assumed it was children.

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