Character gets stuck on platform sprite

Get help using Construct 2

Post » Sun Jan 27, 2013 9:17 am

.capx file here: https://www.sugarsync.com/pf/D6025908_4317202_6583129

Hello all!
My current problem rests in a "little" obstruction or...I don't know what it is...that stops Mr Stick (that's the stick man you can control) from moving forward just as he reaches the apex of the two-triangle incline (made of two instances of the platform45Slanted sprite object.

Once the .capx loads, simply start running to the right (A and D to move left and right, W to jump) and once the PlayerBox (the sprite objected that the MrStick image is set to) reaches the top of the first slanted platform instance and apparently collides with the second, it just gets stuck.

This doesn't happen 100% of time and doesn't seem to happen again after the first time (ie: you move away and come back again). I have Dr Box (that's the box with "evil" eyes) running on Simulate Platform movement and I've noticed he occasionally gets stuck, too...usually after Mr Stick is already stuck. But it seems to happen much less with Dr Box.

I have checked the collision polygon settings for BOTH instances of the slanted platform sprite. It's a triangle shape stretched as far as each point can go to their appropriate corners of the sprite. Both sprites on are equal in terms of the Y-axis. Both are the same size.

The ONLY possible explanation I can think of is that there is (I THINK) a pixel-wide space between the two instances. I haven't devised a way to test this or if it's even the actual problem.

Could someone poke around see what they can find, please? Thank you, much!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Mon Jan 28, 2013 10:01 pm

*bump* My apologies if the bump is too soon as I only posted this yesterday, but it was already on page 4. I was afraid it would get lost with no reply.Rhindon2013-01-28 22:02:01
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Mon Jan 28, 2013 10:40 pm

You should use a non changing invisible rectangular collision sprite as your character and then stick the stickman graphics on top and set it so it follows the invisible collision.
Why?
Because here you're collision is resized to fit your character while he is running.
When you the frame changes from 1 (narrow collision) to 0 (wider collision) and when you're on slanted surface, the bottom corner of the rectangle collision gets into the surface collision. Usually you have a push off algorithm going on, but well... You can get stuck.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 28, 2013 11:39 pm

What Yann said...

I learned this lesson the hard way as well.
B
13
S
4
G
3
Posts: 75
Reputation: 3,425

Post » Tue Jan 29, 2013 6:15 am

@Yann - *BLINKS* Well, that's news to me. I assumed my PlayerBox sprite was staying uniform in size and not adjusting despite the frames of the MrStick sprite. If that's the case, how do I keep the PlayerBox sprite (or the collision lines, as you said) from resizing? And thank you very much for checking it out for me.

@RangerJim - First, I LOVE that you have a Pixar character for your avatar. Second, thank you for also checking it out and confirming what Yann shared.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Jan 29, 2013 9:05 am

1. clone your player object (rightClick clone and click on the viewport)
2. rename it "playerSkin"
3. edit your player object, delete all animations, delete all the frame of the default animation, and just put a rectangle on frame 0.
This way you won't have to rewrite most of the code
4. on event sheet do an "always -> playerSkin set position to player"
5. just for the part concerning the animation on your event sheet, rewire that on the playerSkin object

And be carefull about origin, put everything on the bottom it's easier
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 29, 2013 9:30 pm

@Yann - Forgive me...I'm a tad confused.
Am I cloning my PlayerBox - that which the player actually CONTROLS but is invisible - or am I cloning the MrStick sprite that the player sees when playing the game?

I haven't yet done as you suggested, but I did try editing the origin point on my PlayerBox. APPARENTLY, moving the origin point on the PlayerBox down one pixel seems to have fixed the problem...for the moment. The seemingly random nature of when the collision with the platform sprite makes it difficult to tell.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Jan 29, 2013 11:07 pm

well it's common practice to use an invisible rectangle as your true character and make the graphics/animation of your character follows it.

What I discribed earlier is just the step to follow to have the least amount of thing to change in your event.
Mainly transforming the original player sprite into the aforementionned rectangle (so you still control it) but before, you clone it to create a new object but with your animations in it, so you just have to re write the events concerning animation to target this new clone (clone isn't an instance by the way it's a whole new object)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 29, 2013 11:31 pm

@Yann - Oooooh! Okay. I gotcha now. Actually, that IS what I was doing, but when I saved the .capx to be shared, I forgot to set the PlayerBox (the object actually being controlled) back to invisible. I do have my MrStick character (images and animations and all) set to follow the PlayerBox.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Wed Jan 30, 2013 12:36 am

Oh, indeed, my bad, you can discard all my replies I didn't see you were already doing what I discribed (:

So for now I don't know why you have collision bugs, one of my hypothesis at some point was imprecision in the collision polygon or in the shape's position. But it seems you were pretty cautious here.

So, dunno (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt and 19 guests