How to determine how high to jump using swipe?
CodeCell
Member Posts: 90
Hi Hello,
I was playing around with @StormyStudio template about orbiting and jumping. What I am trying to achieve is that you have to touch and swipe it forward and up to jump. But the faster the swipe the fast and higher the jump will be. At the moment I have tried using Magnitude to determine a height and recognise a swipe but its a constant speed and doesn't look great.
The effect I am looking for is the affect you would get on angry birds Space if you touch and flicked the bird rather than using a slingshot.
What direction should I be taking with this one?
Comments
Im still new to GS so my contribution may be useless but I think it may have something to do with linear velocity? Hope I am at least close...
You would need to determine the speed of the swipe by using a game integer and do…
Constrain Game.Speed to magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )
If your constraining your actor to the mouse it won't work but theres a way around that by using…
Constrain Motion.Linear Velocity.X to 20*( game.Mouse.Position.X - self.Position.X )
Constrain Motion.Linear Velocity.Y to 20*( game.Mouse.Position.Y - self.Position.Y )
Change the 20 to suit…higher the number the faster the actor will react.
Darren.
That's works just if an actor is stationary. However the actor is rotating around in a circle.
And to do this it is only constraining its position and rotation to the centre of its rotation., such as the centre of the screen, which would mean there is no to adjust the speed that it's travelling around the circle. Thank you
It means I going to , or if anyone knows away, research away where I can control the speed it's travelling around. This may be more complicated than I thought. Time to bring out those big complex maths books.
Nothing is ever useless, it's only useless if it's not said. Thanks, I been playing around with it, like Darren has said. But it means I need to find a new way to calculate the speed for the actor rotating.
Okay, if I'm understanding you correctly, you're using @StormyStudio's planet hop template, and are wanting to make it so a swipe causes the jump, and the speed of the swipe dictates the speed and height of the jump?
Having just taken a look at the template, it seems the jump is controlled by an interpolate. This makes it, assuming I've understood correctly, really quite simple.
As such, changing the speed should be pretty simple.
Assuming I'm understanding what you're asking, and it's very much possible I'm not
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline
Velocity equals speed /time. That part was simple. Yes it is the planet and actor rotating around.
However the swipe's direction should alter the direction of the jump. Hopefully the below image can explain it easier:
http://www.mediafire.com/view/3gx549ga61vxevu/Swipe_1.png
(Don't know how to make it show up, seem to be having issues with internet)
As the image shows, a swipe at a 45 degrees would have a different effect to 180 degree swipe, same applies for swipe speed, the smaller the radius zone would be. I have a feeling it involves maths formulas.
Unfortunately I can't get that image to load, but based on what you said, the only addition you need to my previous post is to calculate the direction of the swipe, which is fairly simple. I'll throw together an example file shortly (I have one 2/3 made somewhere anyhow). Working out if a swipe is up/down/left/right is just a matter of a tiny bit of simple maths, but it does get a little more complicated when you want to take into account diagonals, or precise angles. Still very much possible though.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support