How do I move a sprite relatively to another moving sprite

Get help using Construct 2

Post » Thu Jul 03, 2014 12:09 pm

Hi guys,

In the game I'm trying to make (top down view), my characters can move in a grid made of 32 * 32 cells. This is usually working fine apart from a little bug.

At the moment, they can move in a spaceship, like in Faster Than Light basically.

If the ship moves, let's say by 96px to the right, and a character is also moving to the bottom, the character ends up out of the ship. I'd like the character to move relatively to the position of the ship.

How would you do that? Do you think you can achieve this with the pin behaviour?

Thanks,

EDIT: I Forgot to mention that I was using the MoveTo plugin if that makes any difference :)
B
12
S
2
Posts: 85
Reputation: 899

Post » Thu Jul 03, 2014 1:39 pm

pin behaviour should work fine
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Post » Thu Jul 03, 2014 1:53 pm

But, wouldn't pin keep him from moving the object on the platform (ship)?

As far as I understood, he wants the avatar to inherit the vertical and horizontal speeds of the platform, so it doesn't fall behind it, while allowing him to move the avatar on the platform itself.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Thu Jul 03, 2014 1:59 pm

I'm not sure if that is what you are after, also I never used the MoveTo behaviour.
But in case you want to move an object on top of another moving object, a key to make this work is to add the bototom object velocity to the top object velocity.

Something like this:

Top object overlaps bottom object at offset 0,5 (or -5, not sure)

> TopObject > set position > topObject.x + bottomObject.velocity.x, topObject.y + bottomObject.velocity.y
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Thu Jul 03, 2014 2:31 pm

@caiorosisca Actually, this wouldn't work. He must add together player velocity and platform velocity for both axis (horizontal and vertical) or else the player object would only move together with the platform object but wouldn't be able to move on it. In other words, this solution would work exactly as a position pin.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Thu Jul 03, 2014 2:37 pm

@brunopalermo You are right, not sure what I was thinking when I wrote that out. What you need to do is to sum the bottomObject velocity to the topObject velocity and not set it's position. Thanks for pointing that ou
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Thu Jul 03, 2014 3:39 pm

I made an example...

You can check a preview here:

http://examples.gamesintheattic.com/platforminertia/

and get the .capx here:

http://examples.gamesintheattic.com/platforminertia.capx
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Thu Jul 03, 2014 3:48 pm

Awesome, thanks guys, I really appreciate it!

@brunopalermo Thanks a lot for making a capx, I'll test it when I get home. Don't have internet right now, so I'll reply tomorrow when I get back to work to let you know if I managed to integrate this to my little project :)
B
12
S
2
Posts: 85
Reputation: 899

Post » Fri Jul 04, 2014 12:47 pm

I have tested it and checked out the logic. I'm going to see how i can integrate it to my little project, but I think I'm going to struggle a bit! Thanks a lot for your help :)
B
12
S
2
Posts: 85
Reputation: 899


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests