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

Get help using Construct 2

Post » Mon Jun 16, 2014 5:12 pm

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.
B
6
S
2
G
1
Posts: 10
Reputation: 905

Post » Mon Jun 16, 2014 6:07 pm

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

Test (1).capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Jun 16, 2014 7:47 pm

Minor wrote:Here's a fixed version. I think it's the effect you are after.

Test (1).capx

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.
B
6
S
2
G
1
Posts: 10
Reputation: 905

Post » Mon Jun 16, 2014 8:08 pm

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.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Jun 16, 2014 10:24 pm

Minor wrote: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.
B
6
S
2
G
1
Posts: 10
Reputation: 905


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests