How do I create advanced controls+animations?

Get help using Construct 2

Post » Thu Jun 26, 2014 5:02 pm

Ok, here's the deal:

So we've got the main idea of the game we want to create.
Now i've started to work on the very basics, to see if the gameplay will be actually possible. And if it's going to be fun that way.

Our most desire: great controls.
without that, any game is going to be... yea you know.

Please note:
The camera Angle is ISOMETRIC (diablo style)

Controls:
8-way Movement with keyboard.
I've tested this one already, and i was able to create a great animation using Diablo Character Sheets (just for testing of course) based on the direction the character is walking to.

Now, i want to improve the controls and go a step further.
I'm looking for a 8-way movement with keyboard.
BUT rather than the character is looking in the direction indicated by the keyboard walking.
The character shall always look into direction of the mouse cursor!

So you can AIM (for shooting / hitting) with the mouse.

However things will get more complicated ones the character animation shall go backwards, if you're aiming into the other direction than you're walking to. (shooting while walking backwards for example)
I guess it will require quite a few events.


I wasn't able to find any tutorial for this kind of controls, and we would be happy to get some support from you guys.



Also on a sidenote:
The game shall also support multiplayer (at least 4 players)



Thanks in advance for your support!
Last edited by Everade on Sat Jun 28, 2014 11:21 am, edited 1 time in total.
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Post » Fri Jun 27, 2014 11:34 pm

I just got Construct 2 and am planning to make a bullet-hell kind of shooter as my first experimental project (something along the lines of Realm of the Mad God). I'm also trying to figure out how to implement this type of player movement but at the moment I'm totally stumped!

I've tried a few tutorials on Direction-Based Sprite Movement and Aiming and Moving Independently, and was able to get a character to move and fire in separate directions; however, I have yet to figure out how to get the character to stay facing the mouse cursor while moving backwards, for example. Anyone care to share any nuggets of wisdom? :D
B
14
S
6
G
4
Posts: 2
Reputation: 3,261

Post » Fri Jun 27, 2014 11:40 pm

You can use a condition that says "if mouse is top right of player, player looks top right" by using the Mouse.X and Mouse.Y to pinpoint where the mouse actually is.
When using the 8 movement directional behavior you can "Set Angle" to "No" at the left of your screen so the angle doesn't change when moving.

I hope this helped you a little in the direction you want to go
B
6
S
1
Posts: 73
Reputation: 571

Post » Fri Jun 27, 2014 11:43 pm

You got stuck with the exact same issue like me ^^

By the way:
I've got the multiplayer part managed.

The biggest issue i'm facing is still the movement / aiming / animation combination as Vespyr has described above.
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Post » Fri Jun 27, 2014 11:51 pm

rezagamertag:

That does not help in this case i think.

The angle is set to no, i can move just fine without the sprite to rotate.
As i've said, i'm talking about an isometric game style.

So the ANIMATION should change depending on:
> Direction the Cursor is pointing, compared to your player position
while
> Additionaly run animation backwards depending on player movement

I think my description just gave me an idea how to be able to do it.
I'm gonna try it tomorrow ^^

However support is still welcome.
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Post » Fri Jun 27, 2014 11:59 pm

Which gives you 2 conditions to meet:
- Are you moving backwards?
- What direction is the mouse pointing?

For both you will have seperate events like for example

If moving backwards & mouse is top right: do this
If not moving backwards & mouse is top right: do this
If moving backwards & mouse is top left: do this
And so forth.

That's my 2 cents
B
6
S
1
Posts: 73
Reputation: 571

Post » Sat Jun 28, 2014 10:48 am

Image

With 360 cursor aiming (cursor)
With 360 player movement (keyboard)

There is no possibility to simply set "If moving backwards" <----- That's the issue we're having here!
We need something like "If player is moving away from cursor position = set animation reverse"
+ Set Animation Right If cursor position is >29 & < 31 degrees from player location
+ Set Animation DownRight If cursor position is >30 & <61 degrees from player location
+ Set Animation Down If cursor position is >60 & <100 degrees from player location
etc......

Set STANCE animation as well if not walking, so another 8 different animatons

So there's quite a few things we have to do here!!
Not just 2 simple checks....

There's not simply ONE backwards walking. It's 360 degrees possible to walk either back or forth.
(Back and forth can be triggered by reversing the animation i guess.)
So 8 different walking animations looking into 8 different directions:
Up
Down
Left
Right
UpRight
UpLeft
DownRight
DownLeft

Vespyr's issue might be possible with just an upright check.
But not what i'm willing to do.



Here a complete character sheet i will require for walking into all directions:
Image
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Post » Sat Jun 28, 2014 12:51 pm

This might simplify things a bit.

Rename the animations to Angle1,...,Angle8 based on:
Angle1 = 0 to 45 degrees
Angle2 = 46 to 90 degrees
Angle3 = 91 to 135 degrees
Angle4 = 136 to 180 degrees
Angle5 = 181 to 225 degrees
Angle6 = 226 to 270 degrees
Angle7 = 271 to 315 degrees
Angle8 = 316 to 359 degrees

Then set the animation based on the angle between the player and the mouse:

Code: Select all
System->Set aim_angle to angle(Player.X,Player.Y,Mouse.X,Mouse.Y)

System->Set aim_angle to aim_angle < 0 ? aim_angle + 360 : aim_angle

Player->Set animation "Angle" & 1 + floor(aim_angle/45)


This way they should look in the right direction and to get them to appear to be walking backwards check the difference between the player angle and aim_angle and if it is great enough put the animation in reverse.

The easy way to get the player angle is to leave the 8 Direction Set Angle property at 360 Degrees (smooth). Only problem with this is it rotates your character, so you need to set the Player.Angle to 0 after you do your checks every tick.

Code: Select all
System->abs(Player.Angle - aim_angle) > 90
   Player->Set animation speed = -1 * Player.AnimationSpeed
Else
   Player->Set animation speed = abs(Player.AnimationSpeed)

Player->Set angle to 0
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,780

Post » Sat Jun 28, 2014 7:07 pm

The easy way to get the player angle is to leave the 8 Direction Set Angle property at 360 Degrees (smooth). Only problem with this is it rotates your character, so you need to set the Player.Angle to 0 after you do your checks every tick.


I know what you mean, i've handled this issue already before by simply adding the actual animation sprite on top of the player itself.
So the player is set to invisible.
And rather than pinning the animation sprite to the player, i have set it's position to player every tick.
i'm just not sure if that's such a good idea as in performance perspective.


But thanks a lot for your help!
Going to test everything now.
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Post » Sat Jun 28, 2014 8:00 pm

Image


Thanks a lot!

This little piece already did the trick to be able to change the animation based on cursor location.
I will just have to work this whole thing out now.

I will try to add animation upon walking now and finish the whole basic movements.
B
40
S
8
G
3
Posts: 159
Reputation: 3,019

Next

Return to How do I....?

Who is online

Users browsing this forum: atmas, engin20020, gamecorpstudio, rbailey83, tarek2 and 28 guests