[Help] Problem with Go To Layout

Discussion and feedback on Construct 2

Post » Wed Nov 06, 2013 3:04 am

Hi! How are you?
I'm new at Construct 2. I'm trying to make a school project about a game that i really like: Pokemon (GBA style).

I was able to make a smooth grid movement to it following some tutorials.
I added a sprite-based animation to the character as well.
All was going great till i got to "travel" part.

Everything looks buggy now, when i try to move my char, the visual object goes to random locations. I've added a little of code but everything seems to be broken. I'm loosing my mind. Anyone can help me?

Here's the project: h t t p s : //db.tt/g5nxXytE

Thanks a lot!
B
4
Posts: 6
Reputation: 337

Post » Wed Nov 06, 2013 4:31 am

Ah, found the problem.

Here it is fixed, and annotated in the comments
https://db.tt/FYRfoCZ9

See what was happening was you were setting the player position right before you pinned your animations to the player. But you had your pin set to remember the position relative to the object. This meant that your objects were very far apart, and as the player moved and rotated your player sprite went all over the place.

So I set them to be at the same position, then pinned. Problem solved.

Note that it LOOKS a little funny in the player, because it will look like there are times when your player and animations don't match. However, that is a visual only bug, due to the way you have the bullet. Because you are setting the angle of the bullet, it is setting the angle of the sprite.   If you look, they always have the same position, the player sprite is just rotating around the upperleft corner, causing it to appear out of alignment when walking anything other than right. If you run it through the debugger, you can see they actually are at the same position. Just don't use that player for collision, and you'll be okay.


If you do want to use the player for collision, I would recommend using Lerp and doing an actual linear interpolation (keep track of the move timer yourself and update it every frame, don't feed the position back into the Lerp, that performs asymptotic movement. PixelHero2013-11-06 04:32:23
B
15
S
5
G
2
Posts: 24
Reputation: 2,059

Post » Wed Nov 06, 2013 2:43 pm

That was it! Great then, i tried the "Go To Layout" action and it works like a charm.
Your solution works great! The example uses an object (wallDetector) that it's used to detect collisions on overlapping.
Thanks a lot.
B
4
Posts: 6
Reputation: 337


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests