Steering actuator vibrating moving

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)

Hope this is what you want: Movimiento J (3).blend (667 KB)

One of the main problems lies with the velocity - if you use a steering actuator and set too high a velocity increment value, the seeker will likely increment its distance too far from the target once it is really close, then attempt to increment back to the target (missing the target once again), which gives you a back and forth seeking motion of the seeker.

For my machine, a distance of “22” was the lowest distance the seeker would over-increment (you can look at the code I sent). You might have to change this value (not sure if it will be different for your machine, but it probably is).

Please also note that I used an ‘always’ actuator to continually check the distance. Deactivating the actuator sounds like a good idea to stop the movement completely.

Thanks a lot Mirror|rorriM

I think with you .blend modified its enought to resolve my problem.

Thank you.

You’re welcome!