Any ideas?
Blitz3D Forums/Blitz3D Programming/Any ideas?
| ||
Hi, I am using an analogue potentiometer as input via serial port into B3d. The pot readings are as follows: 600 = fully left, 500 = middle, 400 fully right, and of course anywhere in-between. I want to use the input to steer with momentum, so if I am going right (400) and I swing the pot to the left (600) I want the effect to seem to occur gradually as though the momentum is keeping me going right for a short while. I have implemented an array and I am using an index to read from the array based on the potentiometer reading, but if I move right and then left ( but keep the reading right of centre i.e. greater than 500) the movement does not act accordingly. Any thought on how to approach this please?? IPete2. |
| ||
Graphics3D 1024,768,32,2 cam=CreateCamera() light=CreateLight() PositionEntity cam,0,5,0 RotateEntity cam,90,0,0 mesh=CreateCube() EntityFX mesh,1 angle#=0.0 While Not KeyDown(1) If KeyDown(205) angle=angle-.05 If angle<-2 angle=-2 End If If KeyDown(203) angle=angle+.05 If angle>2 angle=2 End If If angle<>0 TurnEntity mesh,0,angle,0 ;Damp angle If angle>0 angle=angle-.005 If angle<0 angle=0 Else If angle<0 angle=angle+.005 If angle>0 angle=0 End If UpdateWorld RenderWorld Flip Wend End Any good? |
| ||
[edit] Ooops, forgot to include momentum on this. Try again:Const POT_SCALE# = 1.0/100.0 pot_val# = (value read from pot) ; Convert pot reading to value in range -1(left) to 1(right). pot_x# = 1.0 - ((pot_val#-400) * POT_SCALE) move# = (move# * 0.99) + (speed# * pot_x#) x# = x# + move# |