How do I set the animation of a created object to the same as the object that created it?

0 favourites
  • 9 posts
From the Asset Store
Create your own Behaviors in Construct 3 using events! Custom Expressions, Signals & Triggers Behavior Addon Pack
  • To explain a little clearer (hopefully)

    I have a family of objects called Shadows

    If an object is on a layer higher than the player, and it's a member of the Shadows family then it spawns a copy of itself on the Shadows Layer.

    What I'd like to achieve is that for the spawned object to have the same animation name and frame number as the object that created it... so ...

    Object 1 is running the Animation "01" and Frame 2 on a higher layer

    Object 1 creates a copy of itself on the shadows layer

    The newly created object changes it's animation to "01" and frame to 2

    Is this possible?

  • It's possible, there just might be problems with picking. Did you first manage to create the copy because if you are using a family this wouldn't normally work as it would create a random object from the family, or are you using create object by name?

  • Thank you for replying lionz

    I was originally using the family to create the family but have now changed it to creating the object by name.

    + Cast_Shadows: On created

    ----+ Cast_Shadows: Is on layer "Above Player - Lower"

    -----> System: Create object Cast_Shadows.ObjectTypeName on layer "Shadows" at (Cast_Shadows.X, Cast_Shadows.Y+50), create hierarchy: False, template: ""

  • Nice, that should be easy then. So if you say 'Create object Shadow', you can then set animation to Family.animation and frame to Family.animationframe, as the Family was picked in the condition. If you picked the actual object in the condition i.e. pick Shadow A then created Shadow A then it will be a bit more diffiult. Should work though with Family object 'Shadows' in condition and then 'create object Shadow'.

  • Ah, that's where I think I'm running into issues.

    So it looks like this ...

    As both objects are effectively being picked by the family Cast_Shadows, this seems to stop me setting the animation name and frame.

  • That looks ok, is that not working? What has gone wrong?

    edit: I see, you can't choose the object in the actions.

    Try this, if you store the animation and frame in a global variable. Then use 'family on last created' and set the animation and frame to the variables. Maybe...

  • It's odd ... it tells me that Cast_Shadows.Animationframe doesn't take a number when there isn't one in the action whatsoever.

    Is it easier in your expert opinion to tag the 'shadow' with a variable identifying the creators UID, then pick via UID and go from there?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I edited the response above, try this. The problem is that you don't know what object will be created so you can't apply actions. If you use Family in the actions then it'll change the one that was created, not the new one. If the above doesn't work then you might have to do logic for individual Shadow objects rather than Family, which isn't that bad.

  • Thank you so much for taking the time out. I think the easiest solution is unfortunately the most lengthy, but I'll continue tinkering! Thank you again!

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