How do I simulate diagonal jump?

Get help using Construct 2

Post » Tue Mar 18, 2014 5:57 pm

Hi guys, this is my first topic here in the forum :D, but I have been 'playing' with C2 for about 2 weeks.

My question is, How do I simulate control of jump, but not only in vertical ? I need something like in the normal platform behavior when up/left or up/right are pressed at same time.

Resuming: When 'left' is pressed, the player goes to his left position, but jumping to there. The same for right button.
I created a gif to illustrate what I want to do:
http:// i.imgur.com/WVvhLMQ .gif (join the url, I'm new so I can't put URL's : p )

A fter seeing this, someone can say "Just add a platform behavior to your
player", but that is not my objective. Because I don't want the player walking on the platforms, just jumping to one platform to another, the jump movement to right/left its just a 'illusion' of control, the Player is fixed in a point on the platform he is. That's why I think I should work with simulate control, but I don't know how to do this.

I don't know if I explained well, but this is my question hehe.
B
3
Posts: 9
Reputation: 218

Post » Tue Mar 18, 2014 6:17 pm

You can add the platform behavior, and then set the controls to NOT default. This way the only movements the player can do are the ones you make in your events.

Now you can do this, add an instance variable to the player called "direction"
When the player presses right set "direction" to 1, and when he presses left set "direction" to -1

Code: Select all
Player.direction = 1
    : Simulate move right
Trigger once
    : Simulate jump


Code: Select all
Player.direction = -1
    : Simulate move left
Trigger once
    : Simulate jump


Code: Select all
Player hits ground (a platform behavior condition)
    : Set Player.direction to 0


Then you can play around with the max speed, acceleration, gravity, etc to get the movement the way you want
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Tue Mar 18, 2014 7:33 pm

Does this work as a starting point? Use the left and right arrows.

I just made a little modification to the file, so if you downloaded it before you might want to try again.
You do not have the required permissions to view the files attached to this post.
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Tue Mar 18, 2014 8:17 pm

This seems to work better
You do not have the required permissions to view the files attached to this post.
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Tue Mar 18, 2014 8:27 pm

@7Soul
You must be running the Beta C2 as I'm not able to open your file, so I'll take your word for it that your's works better. :oops:
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Tue Mar 18, 2014 8:35 pm

@shirokuma Yes it's the latest beta. I used the platform behavior like I said in my previous comment. In your's the physics behavior was causing some unwanted movements, but I think if you stop rotation of the object it helps.
And plus, physics don't interact well with other behaviors so you should avoid it when possible
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Tue Mar 18, 2014 10:16 pm

Wow, thx guys, you're awesome. :D
B
3
Posts: 9
Reputation: 218


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 22 guests