Canceling

Get help using Construct 2

Post » Fri Dec 06, 2013 2:04 am

How you guys handle canceling?

[email protected] If you don't know what canceling is, that's making events stop if event of higher priority happens for example: I attack with melee weapon, but the moment I press the button for jump it immediately stoops attacking ( like in devil may cry for example). So how you'd set priorities for it?megatronx2013-12-06 02:59:10
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
93
S
30
G
22
Posts: 1,987
Reputation: 20,203

Post » Fri Dec 06, 2013 2:50 am

?
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Fri Dec 06, 2013 2:58 am

If you don't know what canceling is, that's making events stop if event of higher priority happens for example: I attack with melee weapon, but the moment I press the button for jump it immediately stoops attacking ( like in devil may cry for example). So how you'd set priorities for it?megatronx2013-12-06 02:58:59
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
93
S
30
G
22
Posts: 1,987
Reputation: 20,203

Post » Fri Dec 06, 2013 4:05 am

Well, say for example you're using the animation "Attack", in which, you have events prepared for damaging, such as;
On Collisions Player + Enemy
+Is "Attack" animation playing
+Is Frame 5 playing
-Do damage

Then making "Cancelling" would be a breeze! Simply detect the jump ("Has Space key been pressed?", "On Jump" in platform behaviour), set animation to "Jump", thus cancelling the rest of the Attack animation!
B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Fri Dec 06, 2013 4:09 am

Your gonig to then need to create a list with priorities. Can't say exactly how to do it. There are many ways. but if we are using your example you don't really need one. Just do the action you pressed. I think what your looking for is to NOT overide current priority as canceling is naturally built into programming.

pc.cur_priority

On Press Attack
if pc.cur_priority < pc.attack_priority
-> pc.animate stuff
-> pc.cur_priotiy = pc.attack_priority<1>

On Press Jump
if pc.cur_priority < pc.jump_priority
-> pc.animation stuff
-> pc.cur_priority = pc.jump_priority<2>

On Press Dash
if pc.cur_priority < pc.dash_priority
-> pc.animation stuff
-> pc.cur_priority = pc.dash_priority<1>

Now as we can see in this simple example assuming that idle = 0.
That from Idle the PC can do any and all action.
However from Attack, Dash cannot be done. But Jump can.
From Jump neither Dash or attack can be performed.

You may want to add timer triggers to reduce priority after a period of time.

On Press Dash
if pc.cur_priority < pc.dash_priority
-> pc.animation stuff
-> pc.cur_priority = pc.dash_priority<1>
-> wait(0.5) -> pc.cur_priority = 0

That way available actions can open up.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests