Hello,
I want to do that a unit moves only 150 blender units. The problem is that when the unit reach the destination position it keeps vibrating.
I think that the problem is with the velocity os steering actuactor. If i put only 1 of velocity there isn’t any problem, but I want to work with 150 of velocity.
The blend is attached. The movement start when click with right mouse, only one time.This is the code:
import bge
def main():
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
clac = cont.sensors ['clac']
cursor = scene.objects ['cursor']
mouseOver = cont.sensors ['mouseOver']
if mouseOver.positive and clac.positive and own['m'] == False:
own['m'] = True
pulsacion = mouseOver.hitPosition
# Mover el cursor donde se ha hecho clac
cursor.position.x = pulsacion.x
cursor.position.y = pulsacion.y
cursor.position.z = pulsacion.z
distancia = int (cursor.getDistanceTo(own))
if distancia > 150: #sustituir por la propiedad de mov de la unidad
print ('Distancia: ', distancia)
cont.actuators['movimiento'].distance = distancia - 150
cont.activate('movimiento')
else:
print ('Distancia: ', distancia)
cont.actuators['movimiento'].distance = 0
cont.activate('movimiento')
main()
The question is: How can i stop the unit when it moves 150 blender units? Any help would be appreciate.
Thanks a lot!
Attachments
Movimiento J.blend (662 KB)