How to get a sliding steering behaviour?

Hi everybody

Can someone help me to get a more realistic flight curve?

https://github.com/galahad9/Airplane/tree/Airplane

Cheers and thanks for reading

Matt

Hi @virtunox,

How do you want to “control” the airplane? Do you want to “draw” the path in advance, or will the user control the path by dragging a touch around?

Brent

Hi Matt,

here is the simple Code for airplane path:

main.lua

local point = {} local plane = nil; local timer1 = nil local pos = 1 local function move() if pos \<= #point then plane.x,plane.y = point[pos].x,point[pos].y pos = pos + 1 end end local function drag(event) if event.phase == "began" then point[#point+1] = {x= event.x,y= event.y} if timer1 ~= nil then timer.cancel(timer1) end elseif event.phase == "moved" then local star = display.newLine( point[#point].x, point[#point].y , event.x,event.y ) point[#point+1] = {x= event.x,y= event.y} elseif event.phase == "ended" then plane = display.newRect(point[pos].x,point[pos].y,10,10) plane.x,plane.y = point[pos].x,point[pos].y timer1 = timer.performWithDelay(20,move,0) end end Runtime:addEventListener("touch",drag)

I think this will help you.

This is just a basic code , you have to police this code for smooth working…

Thank you.
Bhavin :slight_smile:

 

Brent, there is an iOS Game called Flight Control where you are an air traffic controller landing planes at an airport. In the game, you use touch to touch the plane and draw a path to the runway that you want it to fly.  It produces way smoother curves than you can actually draw with your finger. The picture above shows a typical finger drag.  Look at the attached SS from Flight control:

You can see how smooth the lines are.  I don’t have an answer, I’m just adding context to what I think the OP is asking. Curve’s are not my thing.  In the game the curve smooths as you drag your finger along the screen. 

Rob

I did a quick google and found these links that might be of use:

https://en.wikipedia.org/wiki/Smoothing

http://comjnl.oxfordjournals.org/content/29/6/564.full.pdf

The first one is links to a bunch of different smoothing techniques. The second one also offers multiple math formulas too, but looking at the math it made my head hurt.  Maybe someone with more math skills than I have will be able to produce a lovely lua function that takes an array of x, y points, and returns an array of smoothed points.

Rob

Hi @virtunox,

How do you want to “control” the airplane? Do you want to “draw” the path in advance, or will the user control the path by dragging a touch around?

Brent

Hi Matt,

here is the simple Code for airplane path:

main.lua

local point = {} local plane = nil; local timer1 = nil local pos = 1 local function move() if pos \<= #point then plane.x,plane.y = point[pos].x,point[pos].y pos = pos + 1 end end local function drag(event) if event.phase == "began" then point[#point+1] = {x= event.x,y= event.y} if timer1 ~= nil then timer.cancel(timer1) end elseif event.phase == "moved" then local star = display.newLine( point[#point].x, point[#point].y , event.x,event.y ) point[#point+1] = {x= event.x,y= event.y} elseif event.phase == "ended" then plane = display.newRect(point[pos].x,point[pos].y,10,10) plane.x,plane.y = point[pos].x,point[pos].y timer1 = timer.performWithDelay(20,move,0) end end Runtime:addEventListener("touch",drag)

I think this will help you.

This is just a basic code , you have to police this code for smooth working…

Thank you.
Bhavin :slight_smile:

 

Brent, there is an iOS Game called Flight Control where you are an air traffic controller landing planes at an airport. In the game, you use touch to touch the plane and draw a path to the runway that you want it to fly.  It produces way smoother curves than you can actually draw with your finger. The picture above shows a typical finger drag.  Look at the attached SS from Flight control:

You can see how smooth the lines are.  I don’t have an answer, I’m just adding context to what I think the OP is asking. Curve’s are not my thing.  In the game the curve smooths as you drag your finger along the screen. 

Rob

I did a quick google and found these links that might be of use:

https://en.wikipedia.org/wiki/Smoothing

http://comjnl.oxfordjournals.org/content/29/6/564.full.pdf

The first one is links to a bunch of different smoothing techniques. The second one also offers multiple math formulas too, but looking at the math it made my head hurt.  Maybe someone with more math skills than I have will be able to produce a lovely lua function that takes an array of x, y points, and returns an array of smoothed points.

Rob