Making missile randomly pick which actor to collide with
beckb
Member Posts: 16
I'd like to make a missile randomly choose which actor to collide with each time it spawns. There are 3 actors that are possible for it to collide with. Thanks!
Comments
but, have each target report their coords:
Make an integer (game.TargetID) & 7 real game.attributes (for X&Y coords)
on the target actor make an integer (self.ID) and have it choose an ID by using the integer like so:
change attribute self.ID to game.TargetID
change game.TargetID to game.TargetID+1
Now use rules to have the target report its position.
When self.ID = 0
Change game.X0 to self.position.x
Change game.Y0 to self.position.y
When self.ID = 1
Change game.X1 to self.position.x
Change game.Y1 to self.position.y
When self.ID = 2
Change game.X2 to self.position.x
Change game.Y2 to self.position.y
On the missile:
make an integer named RandomTarget.
make 2 real attributes names DestinationX & DestinationY
make 1 Angle attribute named DestinationAngle
Move Direction = DestinationAngle
relative to scene
change self.RandomTarget to random(0,2)
(make one of these rules for each targetID)
When self.RandomTarget = 0
Change self.DestinationX to game.X0
Change self.DestinationY to game.Y0
Constrain self.DestinationAngle to vectortoangle(self.DestinationX-self.position.x,self.DestinationY-self.position.y)