Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Dale on November 18, 2007, 12:55 PM

Title: AI
Post by: Dale on November 18, 2007, 12:55 PM
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.
Title: Re: AI
Post by: Spht on November 18, 2007, 12:59 PM
Depends on the situation, environment, etc

The simplest answer is copy the movements of the thing being followed
Title: Re: AI
Post by: Dale on November 18, 2007, 01:10 PM
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..
Title: Re: AI
Post by: Barabajagal on November 18, 2007, 03:29 PM
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
Title: Re: AI
Post by: Dale on November 18, 2007, 04:49 PM
Works beautifully thanks Andy.
Title: Re: AI
Post by: Barabajagal on November 18, 2007, 05:04 PM
Any time ;)