How do I jump player towards mouse position on left click?

Get help using Construct 2

Post » Fri Mar 28, 2014 9:57 pm

Hey guys, so as the title suggests I hope someone can give me a hint as to the best way to go about this.

I basically just want the player sprite to jump and move in the direction of position Mouse.X and Mouse.Y (if that is the best way of course?) I am using Platform (preferably would like to keep that behaviour) and currently have it set to when 'left mouse released > simulate platform pressing jump'. Of course the next step is the angle and direction.

Some help is kindly appreciated. :)

Thanks!
B
4
Posts: 9
Reputation: 243

Post » Sat Mar 29, 2014 1:39 pm

It may have some issues depending upon exactly what you looking for, but maybe this will get you started. I used Touch instead of Mouse.
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 » Sat Mar 29, 2014 3:51 pm

Hey thanks for that! Definitely serves it's purpose, and actually I do need it for both touch and mouse so it's good.

Now I need to play around with this because actually I need the jump to perform in a more specific way. First thing I noticed now is the touch has to be held down for the jump to complete in either direction. Actually, finally my end goal is to have a mechanic whereby when the player touches in the direction they want to jump, it powers the jump depending on how long they press. A little directional arrow appears when in touch before they jump (this I have already setup). And then of course when they release touch the player fires in the direction they had the arrow and at the power they specified when in touch.

Is this a complicated mechanic to setup? I don't expect anyone to make this for me of course. But again, if you could point me in the right direction of events/actions needed it would be appreciated.

Thanks!
B
4
Posts: 9
Reputation: 243

Post » Sun Mar 30, 2014 8:50 pm

A little bump.

For my question above. How would this be best achieved actually? With behaviour Platform or Custom Movement? I've been playing around with the custom movement but not really achieved what I'm looking for. Platform behaviour is easier to work with but again not achieving what I need for my move mechanic.

Thanks again!
B
4
Posts: 9
Reputation: 243

Post » Mon Mar 31, 2014 2:33 am

Well, here is a start. It still needs work, but I'd need to study some on vector mathematics before I could go farther. :oops:
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 » Mon Mar 31, 2014 3:57 am

I made this for a guy with the same question yesterday viewtopic.php?f=147&t=100612
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Mon Mar 31, 2014 6:28 pm

Wow that's awesome guys thanks so much. I've just opened both and am starting to understand and tinker with them.

Shirokuma you definitely went above and beyond, much appreciated. I've just started tinkering as I said but just one question. I notice with Platform behaviour it seems it is not possible to jump direction down on the Y axis when aiming the direction to the floor for example. Is this actually possible?

Anyway, was just my first quick observation as I said I'm going to play around with this.

Thanks again!
B
4
Posts: 9
Reputation: 243

Post » Mon Mar 31, 2014 7:14 pm

@rheece
I was just discussing vectors with a coworker (an actual programmer instead of a hack like me), and I can say it is possible to calculate a vector in the negative Y direction. In my example I intentionally avoided them thinking that you wouldn't need a negative Y vector because you are standing on a platform, so you can't go that direction. But I guess if you want to do something like that you could add some code that turns off the solidity of the platform you are standing on when you get a negative Y vector.

I should warn you that my vector code isn't correct, so use at your own risk. :?
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Mon Mar 31, 2014 7:30 pm

Haha, ok no worries Shirokuma. Your help was great thanks for taking the time. :)

I was actually just about to reply again mentioning after more playing around with 7Souls example I notice I can indeed jump the player in any desired direction it seems.

So, now I have enough help from you both to get me to the next stage in my game mechanics. Great stuff!
B
4
Posts: 9
Reputation: 243


Return to How do I....?

Who is online

Users browsing this forum: draiza, matriax and 26 guests