Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Smooth movement along curvy objects (as in alto's adventure)
Started by DevilDev May 20 2018 07:39 PM

* * * * * 1 votes
16 replies to this topic
curves smooth transition

Best Answer mmihajlovic , 24 May 2018 - 09:53 AM

I did a little digging and it seems that corona used to have a little sample called tiny penguin which explained this exact thing. It's gone from their github now but someone made a fork: https://github.com/chrisid/TinyPenguin

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

DevilDev

[GLOBAL: userInfoPane.html]
DevilDev
  • Enthusiast

  • 77 posts
  • Corona SDK

vlcsnap-2018-05-21-09h42m48s157.png vlcsnap-2018-05-21-09h42m44s806.png

 

 

How to make a smooth transition as in alto's adventure?

Changing the velocity or gravity doesn't give me smooth transition.How to do that?

Any help or hint is greatly appreciated and welcomed...

Thanks...



[TOPIC: post.html]
#2

DevilDev

[GLOBAL: userInfoPane.html]
DevilDev
  • Enthusiast

  • 77 posts
  • Corona SDK

Please some one give me a prototype or hint....I don't even have an idea on how it works.....



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

I'm not sure I understand the question. The images don't really convey your issue. Maybe you could share some code that you're using, perhaps a screen recording of the simulator showing your issue or zip up your project, put it on DropBox or similar and share a link here so the community can see what you're seeing.

 

Rob



[TOPIC: post.html]
#4

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,377 posts
  • Corona SDK

I have played that game. Although I agree with Rob and don't understand the question. The game has elements that are very similar to this free template:

 

https://marketplace.coronalabs.com/app-templates/endless-sk8boarder



[TOPIC: post.html]
#5

DevilDev

[GLOBAL: userInfoPane.html]
DevilDev
  • Enthusiast

  • 77 posts
  • Corona SDK

Thanks to all.I have trouble in communication. :unsure:  :unsure:

             

            

               

              My doubts is "How to move an object in a circular or elliptical path".

             The blue boxes should move along the curves as shown in the image. 

             Using the same logic,i wanna create an endless runner...

Untitled.png

 

 



[TOPIC: post.html]
#6

DevilDev

[GLOBAL: userInfoPane.html]
DevilDev
  • Enthusiast

  • 77 posts
  • Corona SDK

I have played that game. Although I agree with Rob and don't understand the question. The game has elements that are very similar to this free template:

 

https://marketplace.coronalabs.com/app-templates/endless-sk8boarder

How to make the endless sk8boarder with curve terrains?



[TOPIC: post.html]
#7

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 779 posts
  • Corona SDK

@decoder143 Are you using physics or display transitions?



[TOPIC: post.html]
#8

DevilDev

[GLOBAL: userInfoPane.html]
DevilDev
  • Enthusiast

  • 77 posts
  • Corona SDK

@sporkfin

            I am using physics now.But physics movement is not smooth and i don't know how to move the object along the curve-path..

                           Thanks



[TOPIC: post.html]
#9

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 306 posts
  • Corona SDK

@decoder143 physics won't be perfectly smooth but it will do the job. I think you use them not totally correctly.

If you want to follow a curve you can do it with transition. https://docs.coronalabs.com/api/library/easing/index.html with two transitiond one for x and one for y.

If it's not enough for you, you can do with enterframe and set at each frame the new x and y according to your function or curve



[TOPIC: post.html]
#10

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,373 posts
  • Corona SDK

almost all of this class of game (alto's adventure, hill climb racing, tiny wings, et al, ad nauseum) merely *approximate* curves with straight line geometry.   (i've yet to see one that makes me think they're actually solving nonlinear differential equations in realtime)   if the subdivision is fine enough a player won't notice the difference.



[TOPIC: post.html]
#11

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 779 posts
  • Corona SDK

I haven't tried Alto's Adventure but If you use physics chain bodies for the landscape and circular physics bodies for the character - that should work.  The vertices for the chain bodies will have to be close together, but you can mimic a true circle that way.  I have solved a similar issue this way.

 

However, you will need to keep a constant force on the character to keep it from bouncing off the landscape when it hits bumps.  Density or gravity scale adjustments might help.



[TOPIC: post.html]
#12

mmihajlovic

[GLOBAL: userInfoPane.html]
mmihajlovic
  • Observer

  • 26 posts
  • Corona SDK

This is an interesting question and I can't wait to see what you figured out, since I'm also quite new to this. After reading it I see that there are plenty of questions of box2d (the physics engine corona uses) and curved surfaces. Here's some interesting one's I've found...

 

http://www.box2d.org/forum/viewtopic.php?t=8180 - Circular collisions on curved surfaces

https://gamedev.stackexchange.com/questions/70669/how-do-i-make-a-curved-surface-out-of-rectangular-blocks

 

just google box2d and curved and you'll find loads of question - unfortunately in lots of languages but hey box2d is box2d ;-)

 

Another useful tool I found: https://github.com/jkbmat/Bakalarska-praca an online box2d scene editor to test out physics. Very cool.

 

My theory is your player object would have to be a circle body and the "land" would be some sort of chain body like sporkfin says. Remember the physics body does not have to look like your actual sprite character - you could use the hidden body's x and y to place your sprite and make sure your rotation is correct as per the land.



[TOPIC: post.html]
#13

mmihajlovic

[GLOBAL: userInfoPane.html]
mmihajlovic
  • Observer

  • 26 posts
  • Corona SDK

  Best Answer

I did a little digging and it seems that corona used to have a little sample called tiny penguin which explained this exact thing. It's gone from their github now but someone made a fork: https://github.com/chrisid/TinyPenguin



[TOPIC: post.html]
#14

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,377 posts
  • Corona SDK

Wow it still runs. I mean it has some errors and warnings but it runs on the simulator just fine.



[TOPIC: post.html]
#15

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 779 posts
  • Corona SDK

It uses rectangles to cap the landscape but you could get the same effect with a physics chain body.  The penguin's rotation is controlled by simply setting the rotaion (instead of calling an angular impulse) - the physics body follows without decoupling from the "display" engine. 

 

I wonder if that only works for circular physics bodies?  I'll have to investigate.



[TOPIC: post.html]
#16

mmihajlovic

[GLOBAL: userInfoPane.html]
mmihajlovic
  • Observer

  • 26 posts
  • Corona SDK

I wonder if that only works for circular physics bodies?  I'll have to investigate.

 

I remember reading a long time ago (when playing around with xna) that it was a good way to stop the usual getting stuck on platforms thing that happens with rectangular bodies. I think it was this article https://boxycraft.wordpress.com/2009/06/30/behind-boxboy/ or something similar.



[TOPIC: post.html]
#17

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 779 posts
  • Corona SDK

Agreed! I try to base all of my physics bodies off of circles when possible, especially the small ones.  While Physics Editor works great with medium and large physics bodies, smaller physics bodies can be problematic (the calculations get thrown off because there just aren't enough pixels).  One solution to this is to make everything extra large and then scale down the entire display group.  Other than that, go with circles - in unpredictable interactions, they are less likely to crash the physics engine.




[topic_controls]
[/topic_controls]