im making a drag racing game. i spent like an hour or 2 working out the equations for the gear ratios and what not. i based it off of data collected from gt4(playing the game is why it took me about 2 hours). anyway, i got it all worked out and it should go really good. in fact it pretty much does each gear works fairly good. problem is the game is too good at checking #s. i have my shifting set up as...
function shiftup()
gear = gear+1
end
function shiftdn()
gear = gear-1
end
....
if pad:r() then
shiftup() end
if pad:l() then
shiftdn() end
i also have a gear max and min setup but thats not important. the thing is as soon as i tap r itll keep going. one tap may shift to 2 or 6. is their any way to make some functions or just slow it down? i tried making a seperate function for every gear but that did the same thing.
upCount = 0
downCount = 0
function checkPad()
local pad = Controls.read()
if pad:up() then
upCount = upCount + 1
if upCount == 1 then
shiftUp()
end
else
upCount = 0
end
if pad:down() then
downCount = downCount + 1
if downCount == 1 then
shiftDown()
end
else
downCount = 0
end
end
modify your code to only trigger once per button push.. like above.
Last edited by chaos on Thu Oct 20, 2005 10:38 pm, edited 1 time in total.
LuMo wrote:outch!
added the clean solution (by shine)
to the wiki here
greets
there are some problems with that method.. every time any control changes, it will re-read all controls being held, as if you pressed them a second time.. also, you have no way to know how long each individual control has been held, which is useful in a lot of different situations.