Problem with changing characters and their collision-masks

Get help using Construct 2

Post » Wed Sep 17, 2014 12:55 pm

Hi,

I'm working on a game where you can switch between characters with different shapes (square, triangle, circle) and different abilities (speed, jump strength, etc.). They all should have the physics behaviour in order to interact with other sprites.

What I did: I pinned the sprites to a placeholder and set the z-order (on pressing c = move circle to top of layer, the rest to the bottom). The changing abilities were also set via the event-sheet. Everything fine, but my problem is the changing collision mask. E.G. from square to circle. I tried to connect the character-change with a change to a different animation frame of the placeholder which has the circle collision-mask applied. That doesn't work, the character doesn't change and freezes.

Is that enough/the right information? Can anybody help me with that?

Thanks, Held
B
5
S
1
Posts: 45
Reputation: 463

Post » Wed Sep 17, 2014 1:51 pm

I can think of a lot of reasons for this not working the way you describe it, it would be far easier to solve if you could provide the capx..

First thing is using the pin behaviour combined with the physics behaviour, physics has joints, why not use those?
Second thing is disabling the collision for all objects that are not active (if they are all on screen (only z order controls visibility) they could all be interacting)
Third thing is the placeholder (does it itself have physics behaviour), how have you set it up?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Sep 17, 2014 2:09 pm

Message: Held is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Hi,

I disabled the collision for all except the placeholder.
I don't have a clue, what joints can do for me in this situation. Can you give me a hint or is the manual my friend?

Anyway, heres the capx. Hope wetransfer is alright:Thank you.
B
5
S
1
Posts: 45
Reputation: 463

Post » Wed Sep 17, 2014 2:25 pm

Dropbox Link:https://www.dropbox.com/s/wlw5as2g6e37g3s/changing%20characters%20Project%20-%2017_09_14.capx?dl=0
B
5
S
1
Posts: 45
Reputation: 463

Post » Wed Sep 17, 2014 2:43 pm

Ok.. What I don't get..

Why do the characters have physics behaviour?
What do you expect to happen that is not happening in your example?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Sep 17, 2014 3:04 pm

Oh, I forgot to turn the "Platzhalter" collision mask back from circle to bounding box. Just made a test.

The characters have no physics behaviour yet. I deleted that, cause I got even more weird, shaky appearance. Do they need one?

What doesn't happen, is the changing collision behaviour (not in construct terms) accordingly to the changing of the animation frames and their different collision boxes.

Hope, I can explain it clearly.
B
5
S
1
Posts: 45
Reputation: 463

Post » Wed Sep 17, 2014 3:08 pm

Hi @Held, it seems to me that your setup is a little more complicated than it needs to be ( if I'm understanding right ). Firstly I would make a family in your project. That way if you apply and behaviours to the family anything placed inside ( i.e your characters ) will all receive that same behaviour. Secondly, is there any reason you are using separate sprites for your characters in the first place? These could just be different animations ( each can have its own unique collision box ) that the game can just switch between? Not sure if any of this helps at all as I am not 100% clear on your direction :)

As a side note I see you are using an 'everytick' function to scroll the view. 'everytick' can be a bit of a memory hog, and in this case is redundant as there is a 'scroll too' behaviour that can be added to your player character.
B
7
S
1
Posts: 61
Reputation: 567

Post » Wed Sep 17, 2014 3:30 pm

Firstly, thanks for your help! I appreciate.

I plan, that e.g. the square can beat certain some enemies and the circle don't. That's why I thought global variables and different sprites were the way to go. Is there a way to do that, if I only have one sprite with different animations?

But even more important: I didn't find a way to change the kind of the general collision mask from "bounding bx" to "circle". So, when I change to the circle, on diagonal platforms it shakes like hell. If I choose "circle" from the beginning it's vice versa. The square and triangle are shaking. I thought, with different sprites and a placeholder, I'd avoid that. And that's the point where my problems began. :) I think, a command to change the general collision-type would be one solution. But thats not possible, right?

Thanks for the every tick-hint.
B
5
S
1
Posts: 45
Reputation: 463

Post » Wed Sep 17, 2014 3:58 pm

you do know you can edit the collision polygon inside the image editor, right?

So removed all the physics and removed the platform behaviour from all objects except the placeholder..
And everything is a lot smoother..
You do not have the required permissions to view the files attached to this post.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Sep 17, 2014 9:28 pm

@Held You can make a condition that checks what animation/frame the object is on, so for example: On collision with "Enemy1", if playing animation "Circle" Destroy "Enemy1". That way your game will know what to do if it is playing a different animation.

But there is nothing wrong with using different sprites either, its just a little harder to manage and means you have more code. You could also use Arrays for this but if your new to construct 2 I wouldn't get into them just yet ^_^!

In connection with your collision mesh, if you double click a sprite there is an icon at the bottom of the Left hand side panel in the edit image box that is called set collision polygons, you can set this to be different for each animation or frame ( you can al,so right click to apply the same collision mesh to the entire animation or even ALL animations )
B
7
S
1
Posts: 61
Reputation: 567

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 6 guests