Issues with switching states

Get help using Construct 2

Post » Sat Mar 03, 2012 5:52 am

Hello All,

After following instructions from Kyatric and keepee, I've created an 8 way directional control for a movement I'm trying to create. I've got it so that I'm charging a meter variable attached to the player and after releasing the "action" button J, the state for the player switches to an 8 way movement and has 0 gravity. However, it seems to have cancelled my jumping action and I'm not exactly sure why.

I've tried separating the states into groups and reorganizing and everything else seems to be working fine, despite there being a slightly glitchy movement while the player is in platform state. I'm wondering if I could get some assistance.

Here's the capx:
http://dl.dropbox.com/u/65206613/TestPlatform.capx
B
3
Posts: 8
Reputation: 516

Post » Sat Mar 03, 2012 7:25 am

http://www.scirra.com/forum/platformerchange-behavour-when-overlap-to-swim_topic45549.html

I remember a similar post a while ago.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sun Mar 04, 2012 2:42 am

I was actually following that particular part as a guide. There was also a wordpress tutorial for the same kind of concept. The problem is that everything switches states successfully, but my jump function is gone for some reason.
B
3
Posts: 8
Reputation: 516

Post » Sun Mar 04, 2012 3:31 am

AH I found the reason. I didn't know that construct was incapable of switching behaviors on the fly. The two behaviors were conflicting and cancelling each other out. I think I'm going to try a spawn workaround. Thank you for the help though.
B
3
Posts: 8
Reputation: 516

Post » Sun Mar 04, 2012 3:43 am

This should be what you want

Using two behaviors on a single player sprite at the same time is not really advised.
That's why the player was like hopping even if no key was touched.

Once you disable the non used behavior, things look better.

Also using groups (enabling/disabling them) helps to define precisely "states". Only the code in the activated group is executed.

Also with common code, you can put it after the groups as to be executed each tick anyway.

Let me know if you need more explanations.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Mon Mar 05, 2012 5:18 pm

Wow that definitely helped. I didn't know that you could enable and disable groups like that, so I didn't even think to do a workaround that way. I searched the other forums and there were some workarounds that used the 'pin' function, but I can't get that to work either. I'll play around with the enabling and disabling.

Thank you!
B
3
Posts: 8
Reputation: 516

Post » Mon Mar 12, 2012 4:05 am

Also, you disabled the currentmeter=100 when releasing j. I put this on as to have the full charge be the only time I switched states. Whenever I enable it, it doesn't seem to work anymore.
B
3
Posts: 8
Reputation: 516

Post » Fri Aug 03, 2012 3:17 am

I tried using this technique for switching between the platformer behavior and the 8 way movement behavior, but am having trouble. I set up each behavior within a group and am trying to enable/disable groups based on a global variable called "PlayerState". When I run the program, all I get is a grey screen.

I'm still pretty new so any help is greatly appreciated.

Capx: http://dl.dropbox.com/u/56104169/State%20Change%20Test.capx
B
40
S
11
G
6
Posts: 228
Reputation: 6,951


Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, Lancifer and 24 guests