Pinning animation to randomly spawned enemy

0 favourites
  • 4 posts
From the Asset Store
4 Block Soldiers with different animations, 400x400
  • Hello,

    I'm a new user of Construct 2. I'm working on a 'Space-invaders' inspired game for a university project, but I've run into a bit of trouble getting my sprites to work how I want them.

    So far I've been "every tick, rotate enemy to player.x,player.y, but this just makes them slide feet-first towards the player.

    Reading through a tutorial, I've learned that pinning the animation-sprite to the enemy is the way to go to create the forward/left/right look I want.

    Unfortunately, I've only been able to make this work with the very first enemy (created on the layout load), as any other enemies are created at a random position off-screen, I'm not sure how to go about re-creating this pin for each of them because of the random spawn positions

    My enemy code so far:

    <img src="http://vvcap.net/db/1hwBZGKsbJoL4V2KxajK.png" border="0" />

    Any advice would be greatly appreciated!

  • UPDATE 1

    I've had a play around with an idea I thought wouldn't work because of the random aspect, but apparently it seems quite reliable.

    <img src="http://vvcap.net/db/eu9wKFcSE-PzH1zI-deD.png" border="0" />

    Is this the best way to go about it?

    <center>---------------------------------------------------------</center>

    UPDATE 2

    Okay, so that idea doesn't work.

    The animation-sprite IS pinning to each enemy as it's created, but it isnt reacting to THAT enemies conditions.

    If the enemy turns left, ALL animation sprites onscreen are facing left. If one enemy is destroyed, all animation sprites are destroyed :(

    <img src="http://vvcap.net/db/UhrrcdWOWo4WJ2BGnWeZ.png" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Day 2 -

    Temp fix seems to be a "pin to closest", but I could see this being problematic if there are sprite collisions (maybe pinning to the wrong base?)

    Does anyone have a better solution to this?

  • You could make a container in which you have the enemy-sprite (which could just be an empty sprite set invisible) and the enemy-animation-sprite.

    Now when you create the enemy-sprite, the enemy-animation-sprite is created also. So in a subevent of the create event you could use the pin behaviour to pin the two together.

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