Diagonal Animations don't play in 8-way motion

Get help using Construct 2

Post » Sat Jan 23, 2016 2:09 pm

Hello,

I am trying to create a top down movement similar to RPG Maker type movement except with diagonal movement as well. Currently I have the movement part done and all animations working just fine except those with diagonal motion.

I have a setup where I use custom controls to allow the player to either use WASD or arrow keys. I separated the events for movement away from the animation ones. But despite that the animations don't play when diagonal movement occurs (for example if I press W and D for example).

I tried something else by making a variable on the player itself called "animation" and change it whenever a movement key is pressed. However it does't work on all animations. It works on diagonals and left and right but it doesn't work on Up, Down and Idle animations for some reason.

Here is the .capx file:
https: //drive.google.com/open?id=0B55-vryvL77VTnJSZ3FXcGJpRDA

Sorry to break the link but the forums edits it out
Am I missing something here? Anyone knows how to resolve this issue?

Thank you for your help in advance.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Jan 23, 2016 3:32 pm

The link is wrong..
Says I need permission from the owner to get to the file..

I always use this for movement and animation:
Easy keyboard setup capx
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 » Sat Jan 23, 2016 5:31 pm

https ://www.dropbox.com/s/45fo473r59sqpcs/Game.capx?dl=0

Hate Google Drive in these things. Here is the link again, sorry. I have checked your .capx and I think I have a similar setup only the difference is a private variable instead of a global one and handles only animation.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Jan 23, 2016 6:15 pm

If you name the animations correctly it works..

For example there is no animation called "Down", it's called "Front"

Also Construct2 read events top to bottom, so if you want to use the "right" and animation for up-right and "down-right" you should put those events at the bottom or add conditions to the above event..
Setting the animation to play from current frame might be needed if you choose the first option..

The big difference between my example and what you do is I don't use "key is down", but "on key pressed" just adding and subtracting, so the diagonals are immediatly considered and that's why I don't need to add as many conditions..
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 » Sat Jan 23, 2016 7:04 pm

Well this is really embarrassing now. I didn't notice I gave different names... I need to start making conventions for myself.

That said, I realize what your example does and now I am using it. Thank you very much. My only problem however is that there is no diagonal movement now. I can only have the character moving in the main 4 directions. I tried adding a condition "On key Pressed W" and "On Key Down D" (as it seems construct doesn't like 2x "On key pressed" conditions) to simulate up + left movement with the variable adding 7, it didn't work.

Any idea how to make it work with your method?
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Jan 23, 2016 7:21 pm

Changing it to or blocks should work,

on up pressed
'or'
on W pressed

Problem is that than it would be possible to press both at the same time which would add the number twice..

So probably creating a new event "on W pressed" with an extra condition "keyboard 'up' is not down" and adding W is not down to the on 'up' pressed would be nescessary..
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 » Sat Jan 23, 2016 7:33 pm

That is what I have right now. All the blocks have "On Key Pressed W" or "On Key Pressed Up" simulate control Up (I have 8 way control on the player). But diagonal doesn't work. I made sure that 8-directional is enabled in the behavior too.

As for the addition and subtraction I slightly edited that. Instead of using "Add" and "Subtract". I just use "Set" so I don't have to worry about the player pressing both button options at the same time.

Here is how it looks now:

Image

This setup doesn't allow diagonal movement. If I tried to add a new block with a new number, it still doesn't work. I am guessing to allow diagonal movement I need either to use the default controls + unchanged 8-way behavior or mouse + WASD controls, right?
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Jan 23, 2016 8:44 pm

Vallar wrote:That is what I have right now. All the blocks have "On Key Pressed W" or "On Key Pressed Up" simulate control Up (I have 8 way control on the player). But diagonal doesn't work. I made sure that 8-directional is enabled in the behavior too.

As for the addition and subtraction I slightly edited that. Instead of using "Add" and "Subtract". I just use "Set" so I don't have to worry about the player pressing both button options at the same time.

Here is how it looks now:

Image

This setup doesn't allow diagonal movement. If I tried to add a new block with a new number, it still doesn't work. I am guessing to allow diagonal movement I need either to use the default controls + unchanged 8-way behavior or mouse + WASD controls, right?


Well if you change something, some things change..
I had very specific reasons for using the adding and subtracting..
Not using it the way I set it up makes the setup unusable..

You'd just need events that don't contradict..

if you have an event

up is down

and an event

right is down

and an event

up is down 'and right' is down

all three events are true when both up and right are down..

So you'd need extra conditions to prevent them all from being true at the same time..
The example I made was made to simplify that process..
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 » Sun Jan 24, 2016 6:09 am

LittleStain wrote:
Well if you change something, some things change..
I had very specific reasons for using the adding and subtracting..
Not using it the way I set it up makes the setup unusable..

You'd just need events that don't contradict..

if you have an event

up is down

and an event

right is down

and an event

up is down 'and right' is down

all three events are true when both up and right are down..

So you'd need extra conditions to prevent them all from being true at the same time..
The example I made was made to simplify that process..


Indeed, but if I use the the addition and subtraction with the "Or" condition check, I'll run into the problem you mentioned before. Otherwise I have to do them each on separate conditions like below:
Key Pressed W and NOT Key Pressed Up, add.
Key Pressed Up and NOT Key Pressed W, add.

This would take many events. So I thought the "Set" would work better in this case. I am guessing I'll just end up using the mouse and keyboard for it. Unless there is something I am missing that can be done to allow diagonal motion.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sun Jan 24, 2016 11:14 am

Actually it would be way better to have the player choose which of the two he/she wants to use, or even to choose his/her own keys..

Then using keyboardkeycodes you wouldn't have the above issue anymore..
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

Next

Return to How do I....?

Who is online

Users browsing this forum: Davlin, VulcanSpawnWolf and 1 guest