How do I set height to the distance between two objects?

0 favourites
  • 5 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • Ok, so I sort of have this working already, only it's a little wonky and I can't seem to figure out why.

    Here's my capx: https://dl.dropboxusercontent.com/u/96804667/Test.capx

    In the example, I'm trying to get the "FireFall" sprite to alter it's height depending on the object it is currently overlapping.

    As you can see, it does indeed alter the height, but it still overlaps the object and is just not as accurate as I'd like it to be.

    The wider the object/Fire, the more trouble it has finding the correct height, which is why the Player sprite seems to work almost perfectly, but the Moving Platform is way off.

    Am I missing something super obvious here? I feel like I am. Should I possibly be calculating the width as well?

    Thanks for any and all help guys, this is starting to drive me nuts.

  • Here's a fixed version. I think it's the effect you are after.

    [attachment=0:52z37bd1][/attachment:52z37bd1]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a fixed version. I think it's the effect you are after.

    [attachment=0:2ofl3yby][/attachment:2ofl3yby]

    Perfect!

    Would you mind running me through the logic of why that fixed it?

    It seems simply removing the X of each object and repeating the X of the Fire did the trick? I didn't know you could use repeated co-ordinates like that.

    Thanks a whole bunch.

  • I'll try to explain see if I can make sense

    You were getting the distance using "fireball" X&Y to "moving platform" X&Y, so distance(fireball.x,fireball.y,movingplatform.x,movingplatform.y). So it's actually calculating the length of a diagonal line which is why your version always seemed to be longer than it should.

    My version used distance(fireball.x,fireball.y,fireball.x,movingplatform.y) so since the "X" stayed the same the line calculated is straight.

    Hope that makes some sort of sense. I'm bad explaining with words that's why I usually create examples.

  • I'll try to explain see if I can make sense

    You were getting the distance using "fireball" X&Y to "moving platform" X&Y, so distance(fireball.x,fireball.y,movingplatform.x,movingplatform.y). So it's actually calculating the length of a diagonal line which is why your version always seemed to be longer than it should.

    My version used distance(fireball.x,fireball.y,fireball.x,movingplatform.y) so since the "X" stayed the same the line calculated is straight.

    Hope that makes some sort of sense. I'm bad explaining with words that's why I usually create examples.

    Ah, that makes sense. So simple in the end.

    Thanks again.

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