# Moving a ball to random instances?

Get help using Construct 2

### » Sat Dec 28, 2013 7:39 am

Hi,

I have 3 instances of football players and 1 ball on the pitch.

1. On start, the ball have to move to one random instance of a player
2. On collision with one player, the ball should move to a random instance of another player.

My Problem is: How can I target the two players without the ball?

I need some kind of synthax or path notation wich allows me to adress random instances, like:

on collision:
set angle toward position: player.random (instancevariable 1 or 2)

(and a solution that only a player without ball get the pass)

I had a hard time with the manual and tutorials and it would be great to get a hint here?
B
3
Posts: 2
Reputation: 179

### » Sat Dec 28, 2013 7:44 am

Don't know what you are saying
B
1
Posts: 3
Reputation: 181

### » Sat Dec 28, 2013 7:48 am

Give the players a boolean variable HasBall

when the ball is near the player set it to true, when the ball isn't near the player set it to false.

when the ball collides with the player have the system pick an instance of the player with hasball is false and set the balls direction towards it.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Mon Dec 30, 2013 10:28 am

...thanks a lot LittleStain, I will try it!

@4932004: it's easy, 3 players passing and receiving the ball. Random is for the view of the opponent, like in a real game, he don't know were the ball goes... See it as a small part of a much more complex football match (I mean real football, like we will see in Brazil this summer, only with foot and with a real ball, not an egg... :-)))

B
3
Posts: 2
Reputation: 179

Return to How do I....?

### Who is online

Users browsing this forum: Davoo, Rafison and 6 guests