I must do a program where there is an object that moves forward and backward.
I have created a script which takes from a file.txt a numbers sequence.
If it reads:
0 : go forward
1: go backward
Can I write a script where I give a start position, an end position and a time for moving the object from start position to end position in (for example) 3 seconds? If it is possible, how can I do it?
My script is:
cont = bge.logic.getCurrentController()
own = cont.owner
filename = open(‘filedati.txt’,‘r’)
line = filename.readline()
for word in line.split():
spostamenti = [int(e) for e in line.split()]
for i in spostamenti:
if spostamenti[i] == 0:
…script to move forward from [0,0,0] to [0,2,0] in 3 seconds…
elif spostamenti[i] == 1:
…script to move backward from [0,2,0] to [0,0,0] in 3 seconds…
elif spostamenti[i] == 2:
…script to stand still in the position in which the object is located…