Valhalla Legends Forums Archive | Visual Basic Programming | AI

AuthorMessageTime
dlStevens
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.
November 18, 2007, 6:55 PM
Spht
Depends on the situation, environment, etc

The simplest answer is copy the movements of the thing being followed
November 18, 2007, 6:59 PM
dlStevens
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..
November 18, 2007, 7:10 PM
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:
[code]
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
[/code]
November 18, 2007, 9:29 PM
dlStevens
Works beautifully thanks Andy.
November 18, 2007, 10:49 PM
Barabajagal
Any time ;)
November 18, 2007, 11:04 PM

Search