How do I Make Pinned Objects Collide With Solids

Get help using Construct 2

Post » Tue Mar 24, 2015 5:03 am

G'day All,

I'm having trouble with a pinned object travelling through solid blocks.

I have a character ("Mot") with Platform Behavior. When Mot runs into a Solid "Block", he stops (as would be expected).

Image

Now, Mot can attach different "Legs" that can do different things (move faster, jump higher etc). If you press Space while Mot is touching a set of "Legs" (the green rectangles), then "Mot" is pinned to "Legs", his Platform Behavior is disabled, and the "Legs" Platform Behavior stops ignoring input (if Mot already has Legs, then pressing Space will make him dismount):

Image

Which looks like this:

Image

The problem is, now that Mot is attached to Legs, the Mot sprite no longer interacts with Solid objects:

Image

If I let Mot keep the Platform behavior enabled and just Ignore Input, the pinned sprites shudder against each other.

I have considered making the Legs sprites big enough to cover the whole of the character, but that seems a little excessive, and it seems like there is something simple that I am missing.

Any ideas what the problem might be? Or am I going about the whole thing the wrong way? Should I keep the platform movement on Mot (but have him somehow suspended off the ground)?

Any help would be appreciated. Cheers.
B
7
S
1
Posts: 18
Reputation: 361

Post » Thu Mar 26, 2015 2:37 am

Don't use pin. Try using "Set Position to another Object"
Image
B
75
S
23
G
3
Posts: 672
Reputation: 9,224

Post » Thu Mar 26, 2015 3:38 am

Thanks for the reply @TheDom

I'm already setting the position of "Mot" (the blue box) to an Image Point of "Legs1" (the green rectangle). If I remove the Pin, then "Mot" jumps into position fine, but once you move "Legs1", the legs move, but "Mot" stays in place.

Image

Is there something I am missing? Is there a way to make "Mot" stay attached to "Legs" without the Pin behaviour?
B
7
S
1
Posts: 18
Reputation: 361

Post » Thu Mar 26, 2015 4:47 am

..you can use invisible "PlayerBox" sprite for platform behavior..."Mot" and Legs just pin to "PlayerBox"..
"Legs" is pinned... set "PlayerBox" max speed...set jump strength...else..
Image
B
58
S
23
G
7
Posts: 1,438
Reputation: 10,555

Post » Thu Mar 26, 2015 5:17 am

Hi @korbaach, thanks for the ideas.

"Mot" was always going to be just a Hitbox/Playerbox, with the character sprite attached, but I need to keep the Platform behaviour on "Legs" so that they will fall back to the ground if you detach them while in the air (without Platform, then "Legs" just hang in the air).

What you have suggested is pretty much what I have ended up doing. I'm keeping Platform on "Legs", but not turning on Input at all, while keeping Platform active on "Mot" at all times.

What I have done is make a new animation frame on "Mot" with a larger hitbox to encompass both the character sprite and the "Legs" sprite, then when Legs=Attached, change "Mot" frame and set "Legs" to invisible.

It will take some tweaking to get it all to work with the proper graphics (once I have made them), but I think this is the way for me to go forward.

Eventually I want to make it so the character can jump straight from one set of legs to another without touching the ground, but that is giving me even more trouble than this clipping issue.

Thank you both @TheDom and @korbaach for taking your time to give me a hand.
B
7
S
1
Posts: 18
Reputation: 361

Post » Thu Mar 26, 2015 6:22 am

Mattrix wrote: but I need to keep the Platform behaviour on "Legs" so that they will fall back to the ground if you detach them while in the air (without Platform, then "Legs" just hang in the air).


...add "Legs" variable.. "fall"..... if you detach them while in the air...set "fall" to true(1)

"fall" is true(=1)...."Legs set Y to ...lerp(Legs.Y,ground.Y,dt)
(..or 2*dt..6*dt....etc)

On collision with ground ..set "fall" to false(0)
Image
B
58
S
23
G
7
Posts: 1,438
Reputation: 10,555

Post » Thu Mar 26, 2015 6:55 am

@korbaach ooh, I had seen the word "lerp" used around the place, but didn't know what it was for. I'll have to give this a go when I get the chance. I'll keep you updated with the results.
B
7
S
1
Posts: 18
Reputation: 361

Post » Fri Mar 27, 2015 2:42 am

Hmm, the Lerp seems to do weird things. I can't get "Legs" drop at the right speed, and they actually fall slightly into "Block" when they land (rather than just resting on top of "Block"). Also, If I detach while still on the ground, "Legs" actually slide through "Block" and stop at the bottom of it.

Most of these problems can probably be overcome with additional Events/Actions, but at the moment that is more work than I have time to put into it.

Thanks again for your help @korbaach
B
7
S
1
Posts: 18
Reputation: 361


Return to How do I....?

Who is online

Users browsing this forum: Myrmex, Yahoo [Bot] and 1 guest