Glue an object to animated image points / image origins?

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello everybody,

    When my character is on RUN animation, his head is bumping up and down.

    So I've created a new Image Origin and put it on his forehead on every frame.

    Since I'm new to C2 I would love to see an example file or video?

    I'm trying to do something like this:

    EDIT: The link to the youtube video removed because I'm newbie at the forums.

    Search on YouTube for: "Construct 2 Tutorial- Image Origins" and you'll see what I mean on the 29 seconds of the video.

    A step-by-step explanation from the beginning, will be very helpful.

    Thanks ahead!

    * Sorry about my bad English.

  • I have linked an image of my example below. My example 'glues' a player shadow underneath the player sprite at an image point called "Shadow".

    Let's go through it step by step. First you want to start by creating an event that runs every tick (so basically the refresh rate of the screen the game is being played on). Then, under a new action, select the sprite that you want to be glued to something, then go to 'Set Position'. Once the dialog appears for the X and Y values, enter in:

    For the X coordinate: SpriteToBeStuckTo.ImagePointX("ImagePointName")

    For the Y coordinate: SpriteToBeStuckTo.ImagePointY("ImagePointName")

    Hope this helps!

  • Thank you galacticfan!

    Your explanation is very good, I did exactly what you've explained and it works, but the problem is that there is a delay... so when my character is running (it's not so fast, just a bit slower than the default speed) the helmet/hat is following him...

    So I guess the "Every tick" is not like: "Always" if there is such thing in C2, I have no idea.

    Maybe there is a similar solution using the Pin behaviour? but I'm not sure how to accomplish this exactly.

    Is it possible to use the Pin behaviour to imagePoint X+Y ?

    Thanks ahead!


    Working! I just added a pin action after and it works now!

  • I've created a global number "headVariable = 0"

    and when the player touch the hat/helmet headVariable = 1 and destroy the hat/helmet (there are 2, one out of the layout which will change the position) and one that is for collide and collect.

    So... when I moved the "Every tick" event as a sub-event when headVariable = 1

    it's working on the X only, the bumping head on the Y won't affect it.

    Any idea what I did wrong, or how I make it work when the headVariable = 1 ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, another solution is to use the pin behaviour, it will do exactly the same thing

    You'd have to upload a .capx file for me to see to understand better what is happening. You can do that by going to file and then 'Save as Single File'. From there you should be able to upload it somewhere (a public dropbox link would work) and then post the link.

  • Cool, I'm not allowed to post links yet since I'm still a noob around the forums...

    So I will try to send you the file via PM?


    I guess I'm not allowed to PM either... hehe

    How can I send you the .capx file?

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