# How do I attract objects to other

Get help using Construct 2

### » Sun Apr 20, 2014 5:48 pm

i need that spawned objects are attracted for this other...
like asteroids. when they spawn, go in the spaceship direction.

edit: i'm using the bullet behavior in the asteroids and custom movement in spaceship;
B
20
S
4
Posts: 387
Reputation: 2,274

### » Sun Apr 20, 2014 7:15 pm

oh, and the asteroids rotate on their own axes.. therefore, i don't know how to do this
B
20
S
4
Posts: 387
Reputation: 2,274

### » Sun Apr 20, 2014 8:07 pm

Calculate the angle from your asteroids X,Y values to the spaceships X,Y values. And use that angle in "Set angle of motion" (bullet behavior).

I think you can use the expression "angle(x1, y1, x2, y2)" for that.
B
23
S
7
G
4
Posts: 154
Reputation: 3,754

### » Sun Apr 20, 2014 8:18 pm

5Type wrote:Calculate the angle from your asteroids X,Y values to the spaceships X,Y values. And use that angle in "Set angle of motion" (bullet behavior).

I think you can use the expression "angle(x1, y1, x2, y2)" for that.

I understand the idea, but what about that expression?
B
20
S
4
Posts: 387
Reputation: 2,274

### » Sun Apr 20, 2014 8:57 pm

composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Sun Apr 20, 2014 10:24 pm

eli0s wrote:Something like this..?

http://www.eli0s.com/Tests/SpaceShip.capx

the link is not working here :\
B
20
S
4
Posts: 387
Reputation: 2,274

### » Sun Apr 20, 2014 10:32 pm

What do you mean it's not working? It downloads just fine on my part. Perhaps you have some antivirus or popup blocker in your browser?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Sun Apr 20, 2014 10:43 pm

eli0s wrote:What do you mean it's not working? It downloads just fine on my part. Perhaps you have some antivirus or popup blocker in your browser?

no '-'
perhaps my country is blocked? lol
but the thing is.. i just want the spawned objects to go in my direction (the spaceship).
any tips on this?

just one more thing: how to, when i shoot, spawn 3 bullets with different direction? ex:
1: 90 degrees
2: -15 compared to the first
3: +15 compared to the first

sorry for the 'truck' of questions hehe
..and sorry for the english :b
B
20
S
4
Posts: 387
Reputation: 2,274

### » Sun Apr 20, 2014 10:50 pm

pm your email, I'll send you the file, it will be so much easier if you see the capx... Otherwise for the first part @5Type basically already covered it in terms of code, you have to dig a little into expressions...
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Sun Apr 20, 2014 10:57 pm

eli0s wrote:pm your email, I'll send you the file, it will be so much easier if you see the capx... Otherwise for the first part @5Type basically already covered it in terms of code, you have to dig a little into expressions...

yup.. i've started to learn construct and basics of programming recently.
my email is [email protected]

here is my attempt to do the 3 shots thing: https://db.tt/cUf1UJDm
when the spaceship starts to turn, start the error..
B
20
S
4
Posts: 387
Reputation: 2,274

Next

Return to How do I....?

### Who is online

Users browsing this forum: DH The Animtor, oosyrag and 4 guests