• Welcome to Valhalla Legends Archive.
 

AI

Started by Dale, November 18, 2007, 12:55 PM

Previous topic - Next topic

Dale

With coming up with an artificial intelligent function, how would I have one shape follow another? I've gotten a decent distance formula that works, but How would I make the other shape follow? I'm in desperate need of help tonight.

Thanks.

Spht

Depends on the situation, environment, etc

The simplest answer is copy the movements of the thing being followed

Dale

yeah, but then the movement is static, I'm trying to use a for loop and have the shape work it's way to the other shape... But some reason it's not working either..

Barabajagal

Have a timer that determines the location of the object to follow, and move one increment towards those numbers. For instance, if the first object is at 130, 72 and the second object is at 200,50, you would want to move the second object -1,+1.

Example:

If objFollow.Left > objFind.Left Then
    objFollow.Left = objFollow.Left - 1
ElseIf objFollow.Left < objFind.Left Then
    objFollow.Left = objFollow.Left + 1
End If
If objFollow.Top > objFind.Top Then
    objFollow.Top = objFollow.Top - 1
ElseIf objFollow.Top < objFind.Top Then
    objFollow.Top = objFollow.Top + 1
End If

Dale

Works beautifully thanks Andy.

Barabajagal