# How do I set angle compared to another random angle

Just started using Construct 2? Post your questions here

### » Tue Sep 08, 2015 4:17 am

So, I have objects spawning at random points, moving towards the player, with a random angle +/- a certain degrees, so their angle is never known. When that object is killed, it spawns 2 new objects. I want those 2 new objects to then move out a random +/- degrees in relation to the angle the object they spawned from was moving.

Ex. Object 1 is moving at a 65 degree angle. I want the 2 new objects to start out moving at that 65 degree angle, but then have their own variance of +/-70 degrees

If Object 1 is moving at 20 degrees, then I want +/-70 off of that 20 degree angle.

Currently, the objects that spawn are set to angle (X,y) where x,y is the player
Then rotate clockwise random (-25,25) to give some variance in where they go

So, where do I go from there, to make the new spawned objects move in the direction I want them to (the direction the original object was going)
B
9
S
1
Posts: 49
Reputation: 551

### » Tue Sep 08, 2015 9:08 am

I think you should create the two new obect, before you destroy the old one. In this way you can set up their angle depending on the old object.

Something like:
-objetctA is killed
-> create objectB
-> set objectB.angle = objectA.angle + random
-> create objectC
-> set objectC.angle = objectA.angle + random
-> Destroy objectA
B
10
S
2
G
1
Posts: 51
Reputation: 761

### » Wed Sep 09, 2015 2:24 am

Worked well Borgi thank you. Had to disable collision for object.a first so the 2 new objects wouldn't collide with it. I appreciate your help and knowledge!
B
9
S
1
Posts: 49
Reputation: 551

### » Sun Sep 13, 2015 2:55 am

Borgi, was hoping you could provide more help. Before I was using the bullet behavior, and setting the angle for that wasnt too hard. Now I am using Physics behaviors, and moving objects with impulses. Now, should I be using the apply impulse at angle action, and if so, how exactly do I get that to do what I was trying to do originally.

Currently I have.. Physics impulse 5 at angle objecta.angle +random(-20,20) but my object isnt even moving with that, and not sure why because it seems like it should work.
B
9
S
1
Posts: 49
Reputation: 551